blob: 8b989f851ae7e8aa9b28053c942ffb8d453eeb1a [file] [log] [blame]
Kévin Redon69b92d92019-01-24 16:39:20 +01001/**************************************************************************//**
2 * @file cmsis_compiler.h
3 * @brief CMSIS compiler generic header file
4 * @version V5.0.1
5 * @date 30. January 2017
6 ******************************************************************************/
7/*
8 * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
9 *
10 * SPDX-License-Identifier: Apache-2.0
11 *
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
15 *
16 * www.apache.org/licenses/LICENSE-2.0
17 *
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.
23 */
24
25#ifndef __CMSIS_COMPILER_H
26#define __CMSIS_COMPILER_H
27
28#include <stdint.h>
29
30/*
31 * ARM Compiler 4/5
32 */
33#if defined ( __CC_ARM )
34 #include "cmsis_armcc.h"
35
36
37/*
38 * ARM Compiler 6 (armclang)
39 */
40#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
41 #include "cmsis_armclang.h"
42
43
44/*
45 * GNU Compiler
46 */
47#elif defined ( __GNUC__ )
48 #include "cmsis_gcc.h"
49
50
51/*
52 * IAR Compiler
53 */
54#elif defined ( __ICCARM__ )
55
56 #ifndef __ASM
57 #define __ASM __asm
58 #endif
59 #ifndef __INLINE
60 #define __INLINE inline
61 #endif
62 #ifndef __STATIC_INLINE
63 #define __STATIC_INLINE static inline
64 #endif
65
66 #include <cmsis_iar.h>
67
68 #ifndef __NO_RETURN
69 #define __NO_RETURN __noreturn
70 #endif
71 #ifndef __USED
72 #define __USED __root
73 #endif
74 #ifndef __WEAK
75 #define __WEAK __weak
76 #endif
77 #ifndef __UNALIGNED_UINT32
78 __packed struct T_UINT32 { uint32_t v; };
79 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
80 #endif
81 #ifndef __ALIGNED
82 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
83 #define __ALIGNED(x)
84 #endif
85 #ifndef __PACKED
86 #define __PACKED __packed
87 #endif
88 #ifndef __PACKED_STRUCT
89 #define __PACKED_STRUCT __packed struct
90 #endif
91
92
93/*
94 * TI ARM Compiler
95 */
96#elif defined ( __TI_ARM__ )
97 #include <cmsis_ccs.h>
98
99 #ifndef __ASM
100 #define __ASM __asm
101 #endif
102 #ifndef __INLINE
103 #define __INLINE inline
104 #endif
105 #ifndef __STATIC_INLINE
106 #define __STATIC_INLINE static inline
107 #endif
108 #ifndef __NO_RETURN
109 #define __NO_RETURN __attribute__((noreturn))
110 #endif
111 #ifndef __USED
112 #define __USED __attribute__((used))
113 #endif
114 #ifndef __WEAK
115 #define __WEAK __attribute__((weak))
116 #endif
117 #ifndef __UNALIGNED_UINT32
118 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
119 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
120 #endif
121 #ifndef __ALIGNED
122 #define __ALIGNED(x) __attribute__((aligned(x)))
123 #endif
124 #ifndef __PACKED
125 #define __PACKED __attribute__((packed))
126 #endif
127 #ifndef __PACKED_STRUCT
128 #define __PACKED_STRUCT struct __attribute__((packed))
129 #endif
130
131
132/*
133 * TASKING Compiler
134 */
135#elif defined ( __TASKING__ )
136 /*
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.
140 */
141
142 #ifndef __ASM
143 #define __ASM __asm
144 #endif
145 #ifndef __INLINE
146 #define __INLINE inline
147 #endif
148 #ifndef __STATIC_INLINE
149 #define __STATIC_INLINE static inline
150 #endif
151 #ifndef __NO_RETURN
152 #define __NO_RETURN __attribute__((noreturn))
153 #endif
154 #ifndef __USED
155 #define __USED __attribute__((used))
156 #endif
157 #ifndef __WEAK
158 #define __WEAK __attribute__((weak))
159 #endif
160 #ifndef __UNALIGNED_UINT32
161 struct __packed__ T_UINT32 { uint32_t v; };
162 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
163 #endif
164 #ifndef __ALIGNED
165 #define __ALIGNED(x) __align(x)
166 #endif
167 #ifndef __PACKED
168 #define __PACKED __packed__
169 #endif
170 #ifndef __PACKED_STRUCT
171 #define __PACKED_STRUCT struct __packed__
172 #endif
173
174
175/*
176 * COSMIC Compiler
177 */
178#elif defined ( __CSMC__ )
179 #include <cmsis_csm.h>
180
181 #ifndef __ASM
182 #define __ASM _asm
183 #endif
184 #ifndef __INLINE
185 #define __INLINE inline
186 #endif
187 #ifndef __STATIC_INLINE
188 #define __STATIC_INLINE static inline
189 #endif
190 #ifndef __NO_RETURN
191 // NO RETURN is automatically detected hence no warning here
192 #define __NO_RETURN
193 #endif
194 #ifndef __USED
195 #warning No compiler specific solution for __USED. __USED is ignored.
196 #define __USED
197 #endif
198 #ifndef __WEAK
199 #define __WEAK __weak
200 #endif
201 #ifndef __UNALIGNED_UINT32
202 @packed struct T_UINT32 { uint32_t v; };
203 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
204 #endif
205 #ifndef __ALIGNED
206 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
207 #define __ALIGNED(x)
208 #endif
209 #ifndef __PACKED
210 #define __PACKED @packed
211 #endif
212 #ifndef __PACKED_STRUCT
213 #define __PACKED_STRUCT @packed struct
214 #endif
215
216
217#else
218 #error Unknown compiler.
219#endif
220
221
222#endif /* __CMSIS_COMPILER_H */
223