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