1 /**************************************************************************//**
2 * @file cmsis_compiler.h
3 * @brief CMSIS compiler specific macros, functions, instructions
5 * @date 10. January 2018
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 (armclang)
40 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
41 #include "cmsis_armclang.h"
47 #elif defined ( __GNUC__ )
48 #include "cmsis_gcc.h"
54 #elif defined ( __ICCARM__ )
55 #include "cmsis_iccarm.h"
61 #elif defined ( __TI_ARM__ )
62 #include <cmsis_ccs.h>
68 #define __INLINE inline
70 #ifndef __STATIC_INLINE
71 #define __STATIC_INLINE static inline
73 #ifndef __STATIC_INLINE
74 #define __STATIC_INLINE static inline
76 #ifndef __STATIC_FORCEINLINE
77 #define __STATIC_FORCEINLINE __STATIC_INLINE
80 #define __NO_RETURN __attribute__((noreturn))
82 #ifndef CMSIS_DEPRECATED
83 #define CMSIS_DEPRECATED __attribute__((deprecated))
86 #define __USED __attribute__((used))
89 #define __WEAK __attribute__((weak))
91 #ifndef __UNALIGNED_UINT32
92 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
93 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
96 #define __ALIGNED(x) __attribute__((aligned(x)))
99 #define __PACKED __attribute__((packed))
101 #ifndef __COMPILER_BARRIER
102 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
103 #define __COMPILER_BARRIER() (void)0
110 #elif defined ( __TASKING__ )
112 * The CMSIS functions have been implemented as intrinsics in the compiler.
113 * Please use "carm -?i" to get an up to date list of all intrinsics,
114 * Including the CMSIS ones.
121 #define __INLINE inline
123 #ifndef __STATIC_INLINE
124 #define __STATIC_INLINE static inline
126 #ifndef __STATIC_FORCEINLINE
127 #define __STATIC_FORCEINLINE __STATIC_INLINE
130 #define __NO_RETURN __attribute__((noreturn))
132 #ifndef CMSIS_DEPRECATED
133 #define CMSIS_DEPRECATED __attribute__((deprecated))
136 #define __USED __attribute__((used))
139 #define __WEAK __attribute__((weak))
141 #ifndef __UNALIGNED_UINT32
142 struct __packed__ T_UINT32 { uint32_t v; };
143 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
146 #define __ALIGNED(x) __align(x)
149 #define __PACKED __packed__
151 #ifndef __COMPILER_BARRIER
152 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
153 #define __COMPILER_BARRIER() (void)0
160 #elif defined ( __CSMC__ )
161 #include <cmsis_csm.h>
167 #define __INLINE inline
169 #ifndef __STATIC_INLINE
170 #define __STATIC_INLINE static inline
172 #ifndef __STATIC_FORCEINLINE
173 #define __STATIC_FORCEINLINE __STATIC_INLINE
176 // NO RETURN is automatically detected hence no warning here
180 #warning No compiler specific solution for __USED. __USED is ignored.
183 #ifndef CMSIS_DEPRECATED
184 #warning No compiler specific solution for CMSIS_DEPRECATED. CMSIS_DEPRECATED is ignored.
185 #define CMSIS_DEPRECATED
188 #define __WEAK __weak
190 #ifndef __UNALIGNED_UINT32
191 @packed struct T_UINT32 { uint32_t v; };
192 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
195 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
199 #define __PACKED @packed
201 #ifndef __COMPILER_BARRIER
202 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
203 #define __COMPILER_BARRIER() (void)0
208 #error Unknown compiler.
212 #endif /* __CMSIS_COMPILER_H */