1 /**************************************************************************//**
\r
2 * @file cmsis_compiler.h
\r
3 * @brief CMSIS compiler generic header file
\r
5 * @date 10. January 2018
\r
6 ******************************************************************************/
\r
8 * Copyright (c) 2009-2018 Arm Limited. All rights reserved.
\r
10 * SPDX-License-Identifier: Apache-2.0
\r
12 * Licensed under the Apache License, Version 2.0 (the License); you may
\r
13 * not use this file except in compliance with the License.
\r
14 * You may obtain a copy of the License at
\r
16 * www.apache.org/licenses/LICENSE-2.0
\r
18 * Unless required by applicable law or agreed to in writing, software
\r
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
\r
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
21 * See the License for the specific language governing permissions and
\r
22 * limitations under the License.
\r
25 #ifndef __CMSIS_COMPILER_H
\r
26 #define __CMSIS_COMPILER_H
\r
33 #if defined ( __CC_ARM )
\r
34 #include "cmsis_armcc.h"
\r
38 * Arm Compiler 6 (armclang)
\r
40 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
\r
41 #include "cmsis_armclang.h"
\r
47 #elif defined ( __GNUC__ )
\r
48 #include "cmsis_gcc.h"
\r
54 #elif defined ( __ICCARM__ )
\r
55 #include <cmsis_iccarm.h>
\r
61 #elif defined ( __TI_ARM__ )
\r
62 #include <cmsis_ccs.h>
\r
68 #define __INLINE inline
\r
70 #ifndef __STATIC_INLINE
\r
71 #define __STATIC_INLINE static inline
\r
73 #ifndef __STATIC_FORCEINLINE
\r
74 #define __STATIC_FORCEINLINE __STATIC_INLINE
\r
77 #define __NO_RETURN __attribute__((noreturn))
\r
80 #define __USED __attribute__((used))
\r
83 #define __WEAK __attribute__((weak))
\r
86 #define __PACKED __attribute__((packed))
\r
88 #ifndef __PACKED_STRUCT
\r
89 #define __PACKED_STRUCT struct __attribute__((packed))
\r
91 #ifndef __PACKED_UNION
\r
92 #define __PACKED_UNION union __attribute__((packed))
\r
94 #ifndef __UNALIGNED_UINT32 /* deprecated */
\r
95 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
\r
96 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
\r
98 #ifndef __UNALIGNED_UINT16_WRITE
\r
99 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
\r
100 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
\r
102 #ifndef __UNALIGNED_UINT16_READ
\r
103 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
\r
104 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
\r
106 #ifndef __UNALIGNED_UINT32_WRITE
\r
107 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
\r
108 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
\r
110 #ifndef __UNALIGNED_UINT32_READ
\r
111 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
\r
112 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
\r
115 #define __ALIGNED(x) __attribute__((aligned(x)))
\r
118 #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
\r
126 #elif defined ( __TASKING__ )
\r
128 * The CMSIS functions have been implemented as intrinsics in the compiler.
\r
129 * Please use "carm -?i" to get an up to date list of all intrinsics,
\r
130 * Including the CMSIS ones.
\r
134 #define __ASM __asm
\r
137 #define __INLINE inline
\r
139 #ifndef __STATIC_INLINE
\r
140 #define __STATIC_INLINE static inline
\r
142 #ifndef __STATIC_FORCEINLINE
\r
143 #define __STATIC_FORCEINLINE __STATIC_INLINE
\r
145 #ifndef __NO_RETURN
\r
146 #define __NO_RETURN __attribute__((noreturn))
\r
149 #define __USED __attribute__((used))
\r
152 #define __WEAK __attribute__((weak))
\r
155 #define __PACKED __packed__
\r
157 #ifndef __PACKED_STRUCT
\r
158 #define __PACKED_STRUCT struct __packed__
\r
160 #ifndef __PACKED_UNION
\r
161 #define __PACKED_UNION union __packed__
\r
163 #ifndef __UNALIGNED_UINT32 /* deprecated */
\r
164 struct __packed__ T_UINT32 { uint32_t v; };
\r
165 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
\r
167 #ifndef __UNALIGNED_UINT16_WRITE
\r
168 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
\r
169 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
\r
171 #ifndef __UNALIGNED_UINT16_READ
\r
172 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
\r
173 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
\r
175 #ifndef __UNALIGNED_UINT32_WRITE
\r
176 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
\r
177 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
\r
179 #ifndef __UNALIGNED_UINT32_READ
\r
180 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
\r
181 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
\r
184 #define __ALIGNED(x) __align(x)
\r
187 #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
\r
195 #elif defined ( __CSMC__ )
\r
196 #include <cmsis_csm.h>
\r
202 #define __INLINE inline
\r
204 #ifndef __STATIC_INLINE
\r
205 #define __STATIC_INLINE static inline
\r
207 #ifndef __STATIC_FORCEINLINE
\r
208 #define __STATIC_FORCEINLINE __STATIC_INLINE
\r
210 #ifndef __NO_RETURN
\r
211 // NO RETURN is automatically detected hence no warning here
\r
212 #define __NO_RETURN
\r
215 #warning No compiler specific solution for __USED. __USED is ignored.
\r
219 #define __WEAK __weak
\r
222 #define __PACKED @packed
\r
224 #ifndef __PACKED_STRUCT
\r
225 #define __PACKED_STRUCT @packed struct
\r
227 #ifndef __PACKED_UNION
\r
228 #define __PACKED_UNION @packed union
\r
230 #ifndef __UNALIGNED_UINT32 /* deprecated */
\r
231 @packed struct T_UINT32 { uint32_t v; };
\r
232 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
\r
234 #ifndef __UNALIGNED_UINT16_WRITE
\r
235 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
\r
236 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
\r
238 #ifndef __UNALIGNED_UINT16_READ
\r
239 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
\r
240 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
\r
242 #ifndef __UNALIGNED_UINT32_WRITE
\r
243 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
\r
244 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
\r
246 #ifndef __UNALIGNED_UINT32_READ
\r
247 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
\r
248 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
\r
251 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
\r
252 #define __ALIGNED(x)
\r
255 #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
\r
261 #error Unknown compiler.
\r
265 #endif /* __CMSIS_COMPILER_H */
\r