25 #ifndef __CMSIS_COMPILER_H
26 #define __CMSIS_COMPILER_H
33 #if defined ( __CC_ARM )
34 #include "cmsis_armcc.h"
40 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100)
41 #include "cmsis_armclang_ltm.h"
46 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
47 #include "cmsis_armclang.h"
53 #elif defined ( __GNUC__ )
54 #include "cmsis_gcc.h"
60 #elif defined ( __ICCARM__ )
61 #include <cmsis_iccarm.h>
67 #elif defined ( __TI_ARM__ )
68 #include <cmsis_ccs.h>
74 #define __INLINE inline
76 #ifndef __STATIC_INLINE
77 #define __STATIC_INLINE static inline
79 #ifndef __STATIC_FORCEINLINE
80 #define __STATIC_FORCEINLINE __STATIC_INLINE
83 #define __NO_RETURN __attribute__((noreturn))
86 #define __USED __attribute__((used))
89 #define __WEAK __attribute__((weak))
92 #define __PACKED __attribute__((packed))
94 #ifndef __PACKED_STRUCT
95 #define __PACKED_STRUCT struct __attribute__((packed))
97 #ifndef __PACKED_UNION
98 #define __PACKED_UNION union __attribute__((packed))
100 #ifndef __UNALIGNED_UINT32
102 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
104 #ifndef __UNALIGNED_UINT16_WRITE
106 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
108 #ifndef __UNALIGNED_UINT16_READ
110 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
112 #ifndef __UNALIGNED_UINT32_WRITE
114 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
116 #ifndef __UNALIGNED_UINT32_READ
118 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
121 #define __ALIGNED(x) __attribute__((aligned(x)))
124 #define __RESTRICT __restrict
126 #ifndef __COMPILER_BARRIER
127 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
128 #define __COMPILER_BARRIER() (void)0
135 #elif defined ( __TASKING__ )
146 #define __INLINE inline
148 #ifndef __STATIC_INLINE
149 #define __STATIC_INLINE static inline
151 #ifndef __STATIC_FORCEINLINE
152 #define __STATIC_FORCEINLINE __STATIC_INLINE
155 #define __NO_RETURN __attribute__((noreturn))
158 #define __USED __attribute__((used))
161 #define __WEAK __attribute__((weak))
164 #define __PACKED __packed__
166 #ifndef __PACKED_STRUCT
167 #define __PACKED_STRUCT struct __packed__
169 #ifndef __PACKED_UNION
170 #define __PACKED_UNION union __packed__
172 #ifndef __UNALIGNED_UINT32
173 struct __packed__ T_UINT32 { uint32_t v; };
174 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
176 #ifndef __UNALIGNED_UINT16_WRITE
178 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
180 #ifndef __UNALIGNED_UINT16_READ
182 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
184 #ifndef __UNALIGNED_UINT32_WRITE
186 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
188 #ifndef __UNALIGNED_UINT32_READ
190 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
193 #define __ALIGNED(x) __align(x)
196 #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
199 #ifndef __COMPILER_BARRIER
200 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
201 #define __COMPILER_BARRIER() (void)0
208 #elif defined ( __CSMC__ )
209 #include <cmsis_csm.h>
215 #define __INLINE inline
217 #ifndef __STATIC_INLINE
218 #define __STATIC_INLINE static inline
220 #ifndef __STATIC_FORCEINLINE
221 #define __STATIC_FORCEINLINE __STATIC_INLINE
228 #warning No compiler specific solution for __USED. __USED is ignored.
232 #define __WEAK __weak
235 #define __PACKED @packed
237 #ifndef __PACKED_STRUCT
238 #define __PACKED_STRUCT @packed struct
240 #ifndef __PACKED_UNION
241 #define __PACKED_UNION @packed union
243 #ifndef __UNALIGNED_UINT32
244 @packed
struct T_UINT32 { uint32_t v; };
245 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
247 #ifndef __UNALIGNED_UINT16_WRITE
249 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
251 #ifndef __UNALIGNED_UINT16_READ
253 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
255 #ifndef __UNALIGNED_UINT32_WRITE
257 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
259 #ifndef __UNALIGNED_UINT32_READ
261 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
264 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
268 #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
271 #ifndef __COMPILER_BARRIER
272 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
273 #define __COMPILER_BARRIER() (void)0
278 #error Unknown compiler.