1 /**************************************************************************//**
2 * @file cmsis_compiler.h
3 * @brief CMSIS compiler generic header file
5 * @date 30. January 2017
6 ******************************************************************************/
8 * Copyright (c) 2009-2017 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__ )
60 #define __INLINE inline
62 #ifndef __STATIC_INLINE
63 #define __STATIC_INLINE static inline
66 #include <cmsis_iar.h>
69 #define __NO_RETURN __noreturn
77 #ifndef __UNALIGNED_UINT32
78 __packed struct T_UINT32 { uint32_t v; };
79 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
82 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
86 #define __PACKED __packed
88 #ifndef __PACKED_STRUCT
89 #define __PACKED_STRUCT __packed struct
96 #elif defined ( __TI_ARM__ )
97 #include <cmsis_ccs.h>
103 #define __INLINE inline
105 #ifndef __STATIC_INLINE
106 #define __STATIC_INLINE static inline
109 #define __NO_RETURN __attribute__((noreturn))
112 #define __USED __attribute__((used))
115 #define __WEAK __attribute__((weak))
117 #ifndef __UNALIGNED_UINT32
118 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
119 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
122 #define __ALIGNED(x) __attribute__((aligned(x)))
125 #define __PACKED __attribute__((packed))
127 #ifndef __PACKED_STRUCT
128 #define __PACKED_STRUCT struct __attribute__((packed))
135 #elif defined ( __TASKING__ )
137 * The CMSIS functions have been implemented as intrinsics in the compiler.
138 * Please use "carm -?i" to get an up to date list of all intrinsics,
139 * Including the CMSIS ones.
146 #define __INLINE inline
148 #ifndef __STATIC_INLINE
149 #define __STATIC_INLINE static inline
152 #define __NO_RETURN __attribute__((noreturn))
155 #define __USED __attribute__((used))
158 #define __WEAK __attribute__((weak))
160 #ifndef __UNALIGNED_UINT32
161 struct __packed__ T_UINT32 { uint32_t v; };
162 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
165 #define __ALIGNED(x) __align(x)
168 #define __PACKED __packed__
170 #ifndef __PACKED_STRUCT
171 #define __PACKED_STRUCT struct __packed__
178 #elif defined ( __CSMC__ )
179 #include <cmsis_csm.h>
185 #define __INLINE inline
187 #ifndef __STATIC_INLINE
188 #define __STATIC_INLINE static inline
191 // NO RETURN is automatically detected hence no warning here
195 #warning No compiler specific solution for __USED. __USED is ignored.
199 #define __WEAK __weak
201 #ifndef __UNALIGNED_UINT32
202 @packed struct T_UINT32 { uint32_t v; };
203 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
206 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
210 #define __PACKED @packed
212 #ifndef __PACKED_STRUCT
213 #define __PACKED_STRUCT @packed struct
218 #error Unknown compiler.
222 #endif /* __CMSIS_COMPILER_H */