1 /**************************************************************************//**
2 * @file cmsis_compiler.h
3 * @brief CMSIS compiler specific macros, functions, instructions
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__ )
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
74 #define __NO_RETURN __attribute__((noreturn))
77 #define __USED __attribute__((used))
80 #define __WEAK __attribute__((weak))
82 #ifndef __UNALIGNED_UINT32
83 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
84 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
87 #define __ALIGNED(x) __attribute__((aligned(x)))
90 #define __PACKED __attribute__((packed))
97 #elif defined ( __TASKING__ )
99 * The CMSIS functions have been implemented as intrinsics in the compiler.
100 * Please use "carm -?i" to get an up to date list of all intrinsics,
101 * Including the CMSIS ones.
108 #define __INLINE inline
110 #ifndef __STATIC_INLINE
111 #define __STATIC_INLINE static inline
114 #define __NO_RETURN __attribute__((noreturn))
117 #define __USED __attribute__((used))
120 #define __WEAK __attribute__((weak))
122 #ifndef __UNALIGNED_UINT32
123 struct __packed__ T_UINT32 { uint32_t v; };
124 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
127 #define __ALIGNED(x) __align(x)
130 #define __PACKED __packed__
137 #elif defined ( __CSMC__ )
138 #include <cmsis_csm.h>
144 #define __INLINE inline
146 #ifndef __STATIC_INLINE
147 #define __STATIC_INLINE static inline
150 // NO RETURN is automatically detected hence no warning here
154 #warning No compiler specific solution for __USED. __USED is ignored.
158 #define __WEAK __weak
160 #ifndef __UNALIGNED_UINT32
161 @packed struct T_UINT32 { uint32_t v; };
162 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
165 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
169 #define __PACKED @packed
174 #error Unknown compiler.
178 #endif /* __CMSIS_COMPILER_H */