1 /**************************************************************************//**
2 * @file cmsis_compiler.h
3 * @brief CMSIS compiler specific macros, functions, instructions
5 * @date 01. September 2016
6 ******************************************************************************/
8 * Copyright (c) 2009-2016 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 * http://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_iar.h>
61 #define __INLINE inline
63 #ifndef __STATIC_INLINE
64 #define __STATIC_INLINE static inline
67 #define __NO_RETURN __noreturn
75 #ifndef __UNALIGNED_UINT32
76 __packed struct T_UINT32 { uint32_t v; };
77 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
80 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
84 #define __PACKED __packed
91 #elif defined ( __TI_ARM__ )
92 #include <cmsis_ccs.h>
98 #define __INLINE inline
100 #ifndef __STATIC_INLINE
101 #define __STATIC_INLINE static inline
104 #define __NO_RETURN __attribute__((noreturn))
107 #define __USED __attribute__((used))
110 #define __WEAK __attribute__((weak))
112 #ifndef __UNALIGNED_UINT32
113 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
114 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
117 #define __ALIGNED(x) __attribute__((aligned(x)))
120 #define __PACKED __attribute__((packed))
127 #elif defined ( __TASKING__ )
129 * The CMSIS functions have been implemented as intrinsics in the compiler.
130 * Please use "carm -?i" to get an up to date list of all intrinsics,
131 * Including the CMSIS ones.
138 #define __INLINE inline
140 #ifndef __STATIC_INLINE
141 #define __STATIC_INLINE static inline
144 #define __NO_RETURN __attribute__((noreturn))
147 #define __USED __attribute__((used))
150 #define __WEAK __attribute__((weak))
152 #ifndef __UNALIGNED_UINT32
153 struct __packed__ T_UINT32 { uint32_t v; };
154 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
157 #define __ALIGNED(x) __align(x)
160 #define __PACKED __packed__
167 #elif defined ( __CSMC__ )
168 #include <cmsis_csm.h>
174 #define __INLINE inline
176 #ifndef __STATIC_INLINE
177 #define __STATIC_INLINE static inline
180 #warning No compiler specific solution for __NO_RETURN. __NO_RETURN is ignored.
184 #warning No compiler specific solution for __USED. __USED is ignored.
188 #warning No compiler specific solution for __WEAK. __WEAK is ignored.
191 #ifndef __UNALIGNED_UINT32
192 #warning No compiler specific solution for __UNALIGNED_UINT32. __UNALIGNED_UINT32 is ignored.
193 #define __UNALIGNED_UINT32(x) (*x)
196 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
200 #warning No compiler specific solution for __PACKED. __PACKED is ignored.
206 #error Unknown compiler.
210 #endif /* __CMSIS_COMPILER_H */