MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxClToolchain.h
1/*--------------------------------------------------------------------------*/
2/* Copyright 2022-2023 NXP */
3/* */
4/* SPDX-License-Identifier: BSD-3-Clause */
5/* */
6/* Redistribution and use in source and binary forms, with or without */
7/* modification, are permitted provided that the following conditions are */
8/* met: */
9/* */
10/* 1. Redistributions of source code must retain the above copyright */
11/* notice, this list of conditions and the following disclaimer. */
12/* */
13/* 2. Redistributions in binary form must reproduce the above copyright */
14/* notice, this list of conditions and the following disclaimer in the */
15/* documentation and/or other materials provided with the distribution. */
16/* */
17/* 3. Neither the name of the copyright holder nor the names of its */
18/* contributors may be used to endorse or promote products derived from */
19/* this software without specific prior written permission. */
20/* */
21/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS */
22/* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
23/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
24/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
25/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
26/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
27/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR */
28/* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
29/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
30/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
31/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
32/*--------------------------------------------------------------------------*/
33
34#ifndef COMPILER_TOOLCHAIN_H_
35#define COMPILER_TOOLCHAIN_H_
36
37/* for armclang */
38#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
39 #define CSS_IDATA_SEGMENT __attribute__((section("CSS_IDATA_SEGMENT")))
40 #define CSS_CONST_SEGMENT __attribute__((section("CSS_CONST_SEGMENT")))
41 #define MCUX_FUP_ATTRIBUTE __attribute__((aligned(4))) __attribute__((section("MCUX_OBFUSCATED_FUP_SEGMENT")))
42 #define UNUSED_PARAM __attribute__((unused))
43 /*
44 Use of UNALIGNED on ARMCLANG
45
46 The __unaligned keyword is a type qualifier that tells the compiler to treat the pointer or variable as an unaligned pointer or variable.
47 www.keil.com/support/man/docs/armclang_ref/armclang_ref_pfl1493130433688.htm
48
49 The use of __attribute__((packed)) is incorrect on ARMCLANG
50
51 The packed type attribute specifies that a type must have the smallest possible alignment. This attribute only applies to struct and union types.
52 www.keil.com/support/man/docs/armclang_ref/armclang_ref_chr1393328521340.htm
53
54 -munaligned-access is the default for architectures that support unaligned accesses to data. This default applies to all architectures supported by Arm Compiler for Embedded 6, except Armv6-M, and Armv8-M without the Main Extension.
55 */
56 #define UNALIGNED __unaligned
57 #define MCUX_CSSL_UNUSED(p) ((void) (p))
58 /* Macro for alligning buffers to cpu word */
59 #define ALIGNED __attribute__((aligned(4)))
60
61/* using the gcc toolchain file for both gcc and armgcc */
62#elif defined ( __GNUC__ )
63 #define CSS_IDATA_SEGMENT
64 #define CSS_CONST_SEGMENT
65 #define MCUX_FUP_ATTRIBUTE __attribute__((aligned(4)))
66 #define UNUSED_PARAM __attribute__((unused))
67 #define UNALIGNED
68 /* Macro for alligning buffers to cpu word */
69 #define ALIGNED __attribute__((aligned(4)))
70
71/* for armcc compiler */
72#elif defined ( __CC_ARM )
73 #define CSS_IDATA_SEGMENT __attribute__((section("CSS_IDATA_SEGMENT")))
74 #define CSS_CONST_SEGMENT __attribute__((section("CSS_CONST_SEGMENT")))
75 #define MCUX_FUP_ATTRIBUTE __attribute__((aligned(4))) __attribute__((section("MCUX_OBFUSCATED_FUP_SEGMENT")))
76 #define UNUSED_PARAM __attribute__((unused))
77 #define UNALIGNED __packed
78 /* Macro for alligning buffers to cpu word */
79 #define ALIGNED __attribute__((aligned(4)))
80
81/* for ghs compiler */
82#elif defined ( __ghs__ )
83 #define CSS_IDATA_SEGMENT
84 #define CSS_CONST_SEGMENT
85 #define MCUX_FUP_ATTRIBUTE __attribute__((aligned(4)))
86 #define UNUSED_PARAM __attribute__((unused))
87 #define UNALIGNED
88 /* Macro for alligning buffers to cpu word */
89 #define ALIGNED __attribute__((aligned(4)))
90
91/* for iar compiler */
92#elif defined ( __ICCARM__ )
93 #define CSS_IDATA_SEGMENT __attribute__((section("CSS_IDATA_SEGMENT")))
94 #define CSS_CONST_SEGMENT __attribute__((section("CSS_CONST_SEGMENT")))
95 #define MCUX_FUP_ATTRIBUTE __attribute__((aligned(4))) __attribute__((section(".mcux_obfuscated_fup_segment")))
96 #define UNUSED_PARAM __attribute__((unused))
97 #define UNALIGNED __packed
98 /* Macro for alligning buffers to cpu word */
99 #define ALIGNED __attribute__((aligned(4)))
100
101/* for llvm */
102#elif defined ( __clang__ )
103 #define CSS_IDATA_SEGMENT
104 #define CSS_CONST_SEGMENT
105 #define MCUX_FUP_ATTRIBUTE __attribute__((aligned(4)))
106 #define UNUSED_PARAM __attribute__((unused))
107 #define UNALIGNED
108 /* Macro for alligning buffers to cpu word */
109 #define ALIGNED __attribute__((aligned(4)))
110
111
112#endif
113
114
115#if defined(__ghs__) || defined( __ICCARM__ ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined(__GNUC__)
116 #define GHS_ICCARM_ARMCC_GT_10_5_GNUC
117#endif
118
119#if defined(__ghs__) || defined(__gcc__) || defined(__ICCARM__) || defined(__GNUC__)
120 #define GHS_GCC_ICCARM_GNUC
121#endif
122
123#if defined(__ghs__) || defined(__gcc__) || defined(__ICCARM__)
124 #define GHS_GCC_ICCARM
125#endif
126
127#if defined(__ICCARM__) || defined(__ARMCC_VERSION) || defined(__CC_ARM) || defined(__GNUC__)
128 #define ICCARM_ARMCC_GNUC
129#endif
130
131#if defined(__ICCARM__) || defined(__ARMCC_VERSION) || defined(__GNUC__)
132 #define ICCARM_ARMCLANG_GNUC
133#endif
134
135#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION < 6010050)
136 #define ARMCC_LT_10_5 //6.01 build 0050
137#endif
138
139
140#if defined ( __CC_ARM )
141/* Arm Compiler 4/5 */
142#define MCUX_CL_COMPILER_ARMCC
143#define MCUX_CL_COMPILER_ARM_COMPILER
144
145#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100)
146/* Arm Compiler 6.6 LTM (armclang) */
147#define MCUX_CL_COMPILER_ARMCLANG_LTM
148#define MCUX_CL_COMPILER_ARM_COMPILER
149
150#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
151/* Arm Compiler above 6.10.1 (armclang) */
152#define MCUX_CL_COMPILER_ARMCLANG
153#define MCUX_CL_COMPILER_ARM_COMPILER
154
155#elif defined (_clang_)
156#define MCUX_CL_COMPILER_ARM_COMPILER /* i.e. Version 6.01 build 0019 */
157#endif
158
159
160#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && !defined(inline) && !defined(__cplusplus)
161 #define ARMCC_MSC_VER_NOT_INLINE_NOT_CPP
162#endif
163
164#endif /* COMPILER_TOOLCHAIN_H_ */