MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
cmsis_compiler.h
Go to the documentation of this file.
1/**************************************************************************/
7/*
8 * Copyright (c) 2009-2018 Arm Limited. All rights reserved.
9 *
10 * SPDX-License-Identifier: Apache-2.0
11 *
12 * Licensed under the Apache License, Version 2.0 (the License); you may
13 * not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 */
24
25#ifndef __CMSIS_COMPILER_H
26#define __CMSIS_COMPILER_H
27
28#include <stdint.h>
29
30/*
31 * Arm Compiler 4/5
32 */
33#if defined ( __CC_ARM )
34 #include "cmsis_armcc.h"
35
36
37/*
38 * Arm Compiler 6.6 LTM (armclang)
39 */
40#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100)
41 #include "cmsis_armclang_ltm.h"
42
43 /*
44 * Arm Compiler above 6.10.1 (armclang)
45 */
46#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
47 #include "cmsis_armclang.h"
48
49
50/*
51 * GNU Compiler
52 */
53#elif defined ( __GNUC__ )
54 #include "cmsis_gcc.h"
55
56
57/*
58 * IAR Compiler
59 */
60#elif defined ( __ICCARM__ )
61 #include <cmsis_iccarm.h>
62
63
64/*
65 * TI Arm Compiler
66 */
67#elif defined ( __TI_ARM__ )
68 #include <cmsis_ccs.h>
69
70 #ifndef __ASM
71 #define __ASM __asm
72 #endif
73 #ifndef __INLINE
74 #define __INLINE inline
75 #endif
76 #ifndef __STATIC_INLINE
77 #define __STATIC_INLINE static inline
78 #endif
79 #ifndef __STATIC_FORCEINLINE
80 #define __STATIC_FORCEINLINE __STATIC_INLINE
81 #endif
82 #ifndef __NO_RETURN
83 #define __NO_RETURN __attribute__((noreturn))
84 #endif
85 #ifndef __USED
86 #define __USED __attribute__((used))
87 #endif
88 #ifndef __WEAK
89 #define __WEAK __attribute__((weak))
90 #endif
91 #ifndef __PACKED
92 #define __PACKED __attribute__((packed))
93 #endif
94 #ifndef __PACKED_STRUCT
95 #define __PACKED_STRUCT struct __attribute__((packed))
96 #endif
97 #ifndef __PACKED_UNION
98 #define __PACKED_UNION union __attribute__((packed))
99 #endif
100 #ifndef __UNALIGNED_UINT32 /* deprecated */
101 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
102 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
103 #endif
104 #ifndef __UNALIGNED_UINT16_WRITE
105 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
106 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
107 #endif
108 #ifndef __UNALIGNED_UINT16_READ
109 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
110 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
111 #endif
112 #ifndef __UNALIGNED_UINT32_WRITE
113 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
114 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
115 #endif
116 #ifndef __UNALIGNED_UINT32_READ
117 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
118 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
119 #endif
120 #ifndef __ALIGNED
121 #define __ALIGNED(x) __attribute__((aligned(x)))
122 #endif
123 #ifndef __RESTRICT
124 #define __RESTRICT __restrict
125 #endif
126
127
128/*
129 * TASKING Compiler
130 */
131#elif defined ( __TASKING__ )
132 /*
133 * The CMSIS functions have been implemented as intrinsics in the compiler.
134 * Please use "carm -?i" to get an up to date list of all intrinsics,
135 * Including the CMSIS ones.
136 */
137
138 #ifndef __ASM
139 #define __ASM __asm
140 #endif
141 #ifndef __INLINE
142 #define __INLINE inline
143 #endif
144 #ifndef __STATIC_INLINE
145 #define __STATIC_INLINE static inline
146 #endif
147 #ifndef __STATIC_FORCEINLINE
148 #define __STATIC_FORCEINLINE __STATIC_INLINE
149 #endif
150 #ifndef __NO_RETURN
151 #define __NO_RETURN __attribute__((noreturn))
152 #endif
153 #ifndef __USED
154 #define __USED __attribute__((used))
155 #endif
156 #ifndef __WEAK
157 #define __WEAK __attribute__((weak))
158 #endif
159 #ifndef __PACKED
160 #define __PACKED __packed__
161 #endif
162 #ifndef __PACKED_STRUCT
163 #define __PACKED_STRUCT struct __packed__
164 #endif
165 #ifndef __PACKED_UNION
166 #define __PACKED_UNION union __packed__
167 #endif
168 #ifndef __UNALIGNED_UINT32 /* deprecated */
169 struct __packed__ T_UINT32 { uint32_t v; };
170 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
171 #endif
172 #ifndef __UNALIGNED_UINT16_WRITE
173 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
174 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
175 #endif
176 #ifndef __UNALIGNED_UINT16_READ
177 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
178 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
179 #endif
180 #ifndef __UNALIGNED_UINT32_WRITE
181 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
182 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
183 #endif
184 #ifndef __UNALIGNED_UINT32_READ
185 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
186 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
187 #endif
188 #ifndef __ALIGNED
189 #define __ALIGNED(x) __align(x)
190 #endif
191 #ifndef __RESTRICT
192 #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
193 #define __RESTRICT
194 #endif
195
196
197/*
198 * COSMIC Compiler
199 */
200#elif defined ( __CSMC__ )
201 #include <cmsis_csm.h>
202
203 #ifndef __ASM
204 #define __ASM _asm
205 #endif
206 #ifndef __INLINE
207 #define __INLINE inline
208 #endif
209 #ifndef __STATIC_INLINE
210 #define __STATIC_INLINE static inline
211 #endif
212 #ifndef __STATIC_FORCEINLINE
213 #define __STATIC_FORCEINLINE __STATIC_INLINE
214 #endif
215 #ifndef __NO_RETURN
216 // NO RETURN is automatically detected hence no warning here
217 #define __NO_RETURN
218 #endif
219 #ifndef __USED
220 #warning No compiler specific solution for __USED. __USED is ignored.
221 #define __USED
222 #endif
223 #ifndef __WEAK
224 #define __WEAK __weak
225 #endif
226 #ifndef __PACKED
227 #define __PACKED @packed
228 #endif
229 #ifndef __PACKED_STRUCT
230 #define __PACKED_STRUCT @packed struct
231 #endif
232 #ifndef __PACKED_UNION
233 #define __PACKED_UNION @packed union
234 #endif
235 #ifndef __UNALIGNED_UINT32 /* deprecated */
236 @packed struct T_UINT32 { uint32_t v; };
237 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
238 #endif
239 #ifndef __UNALIGNED_UINT16_WRITE
240 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
241 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
242 #endif
243 #ifndef __UNALIGNED_UINT16_READ
244 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
245 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
246 #endif
247 #ifndef __UNALIGNED_UINT32_WRITE
248 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
249 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
250 #endif
251 #ifndef __UNALIGNED_UINT32_READ
252 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
253 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
254 #endif
255 #ifndef __ALIGNED
256 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
257 #define __ALIGNED(x)
258 #endif
259 #ifndef __RESTRICT
260 #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
261 #define __RESTRICT
262 #endif
263
264/*
265 * GHS Compiler
266 */
267#elif defined ( __ghs__ )
268 #include <cmsis_ghs.h>
269
270#else
271 #error Unknown compiler.
272#endif
273
274
275#endif /* __CMSIS_COMPILER_H */
276
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
Reverse byte order (16 bit).
Definition cmsis_armcc.h:467
CMSIS compiler ARMCC (Arm Compiler 5) header file.
CMSIS compiler armclang (Arm Compiler 6) header file.
CMSIS compiler GCC header file.
CMSIS compiler GHS header file.
CMSIS compiler ICCARM (IAR Compiler for Arm) header file.