1 /**************************************************************************//**
2 * @file cmsis_compiler.h
3 * @brief CMSIS compiler specific macros, functions, instructions
5 * @date 13. November 2022
6 ******************************************************************************/
8 * Copyright (c) 2009-2018 Arm Limited. All rights reserved.
10 * SPDX-License-Identifier: Apache-2.0
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
16 * www.apache.org/licenses/LICENSE-2.0
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.
25 #ifndef __CMSIS_COMPILER_H
26 #define __CMSIS_COMPILER_H
33 #if defined ( __CC_ARM )
34 #include "cmsis_armcc.h"
38 * Arm Compiler 6.6 LTM (armclang)
40 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100)
41 #include "cmsis_armclang_ltm.h"
44 * Arm Compiler above 6.10.1 (armclang)
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))
85 #ifndef CMSIS_DEPRECATED
86 #define CMSIS_DEPRECATED __attribute__((deprecated))
89 #define __USED __attribute__((used))
92 #define __WEAK __attribute__((weak))
95 #define __PACKED __attribute__((packed))
97 #ifndef __PACKED_STRUCT
98 #define __PACKED_STRUCT struct __attribute__((packed))
100 #ifndef __PACKED_UNION
101 #define __PACKED_UNION union __attribute__((packed))
103 #ifndef __UNALIGNED_UINT32 /* deprecated */
104 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
105 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
108 #define __ALIGNED(x) __attribute__((aligned(x)))
111 #define __RESTRICT __restrict
113 #ifndef __COMPILER_BARRIER
114 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
115 #define __COMPILER_BARRIER() (void)0
122 #elif defined ( __TASKING__ )
124 * The CMSIS functions have been implemented as intrinsics in the compiler.
125 * Please use "carm -?i" to get an up to date list of all intrinsics,
126 * Including the CMSIS ones.
133 #define __INLINE inline
135 #ifndef __STATIC_INLINE
136 #define __STATIC_INLINE static inline
138 #ifndef __STATIC_FORCEINLINE
139 #define __STATIC_FORCEINLINE __STATIC_INLINE
142 #define __NO_RETURN __attribute__((noreturn))
144 #ifndef CMSIS_DEPRECATED
145 #define CMSIS_DEPRECATED __attribute__((deprecated))
148 #define __USED __attribute__((used))
151 #define __WEAK __attribute__((weak))
154 #define __PACKED __packed__
156 #ifndef __PACKED_STRUCT
157 #define __PACKED_STRUCT struct __packed__
159 #ifndef __PACKED_UNION
160 #define __PACKED_UNION union __packed__
162 #ifndef __UNALIGNED_UINT32 /* deprecated */
163 struct __packed__ T_UINT32 { uint32_t v; };
164 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
167 #define __ALIGNED(x) __align(x)
170 #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
173 #ifndef __COMPILER_BARRIER
174 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
175 #define __COMPILER_BARRIER() (void)0
182 #elif defined ( __CSMC__ )
183 #include <cmsis_csm.h>
189 #define __INLINE inline
191 #ifndef __STATIC_INLINE
192 #define __STATIC_INLINE static inline
194 #ifndef __STATIC_FORCEINLINE
195 #define __STATIC_FORCEINLINE __STATIC_INLINE
198 // NO RETURN is automatically detected hence no warning here
202 #warning No compiler specific solution for __USED. __USED is ignored.
205 #ifndef CMSIS_DEPRECATED
206 #warning No compiler specific solution for CMSIS_DEPRECATED. CMSIS_DEPRECATED is ignored.
207 #define CMSIS_DEPRECATED
210 #define __WEAK __weak
213 #define __PACKED @packed
215 #ifndef __PACKED_STRUCT
216 #define __PACKED_STRUCT @packed struct
218 #ifndef __PACKED_UNION
219 #define __PACKED_UNION @packed union
221 #ifndef __UNALIGNED_UINT32 /* deprecated */
222 @packed struct T_UINT32 { uint32_t v; };
223 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
226 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
230 #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
233 #ifndef __COMPILER_BARRIER
234 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
235 #define __COMPILER_BARRIER() (void)0
240 #error Unknown compiler.
244 #endif /* __CMSIS_COMPILER_H */