xref: /btstack/port/stm32-l476rg-nucleo-sx1280/Drivers/CMSIS/Include/cmsis_compiler.h (revision 6b8177c56d8d42c688f52897394f8b5eac7ee972)
1*6b8177c5SMatthias Ringwald /**************************************************************************//**
2*6b8177c5SMatthias Ringwald  * @file     cmsis_compiler.h
3*6b8177c5SMatthias Ringwald  * @brief    CMSIS compiler generic header file
4*6b8177c5SMatthias Ringwald  * @version  V5.1.0
5*6b8177c5SMatthias Ringwald  * @date     09. October 2018
6*6b8177c5SMatthias Ringwald  ******************************************************************************/
7*6b8177c5SMatthias Ringwald /*
8*6b8177c5SMatthias Ringwald  * Copyright (c) 2009-2018 Arm Limited. All rights reserved.
9*6b8177c5SMatthias Ringwald  *
10*6b8177c5SMatthias Ringwald  * SPDX-License-Identifier: Apache-2.0
11*6b8177c5SMatthias Ringwald  *
12*6b8177c5SMatthias Ringwald  * Licensed under the Apache License, Version 2.0 (the License); you may
13*6b8177c5SMatthias Ringwald  * not use this file except in compliance with the License.
14*6b8177c5SMatthias Ringwald  * You may obtain a copy of the License at
15*6b8177c5SMatthias Ringwald  *
16*6b8177c5SMatthias Ringwald  * www.apache.org/licenses/LICENSE-2.0
17*6b8177c5SMatthias Ringwald  *
18*6b8177c5SMatthias Ringwald  * Unless required by applicable law or agreed to in writing, software
19*6b8177c5SMatthias Ringwald  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20*6b8177c5SMatthias Ringwald  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21*6b8177c5SMatthias Ringwald  * See the License for the specific language governing permissions and
22*6b8177c5SMatthias Ringwald  * limitations under the License.
23*6b8177c5SMatthias Ringwald  */
24*6b8177c5SMatthias Ringwald 
25*6b8177c5SMatthias Ringwald #ifndef __CMSIS_COMPILER_H
26*6b8177c5SMatthias Ringwald #define __CMSIS_COMPILER_H
27*6b8177c5SMatthias Ringwald 
28*6b8177c5SMatthias Ringwald #include <stdint.h>
29*6b8177c5SMatthias Ringwald 
30*6b8177c5SMatthias Ringwald /*
31*6b8177c5SMatthias Ringwald  * Arm Compiler 4/5
32*6b8177c5SMatthias Ringwald  */
33*6b8177c5SMatthias Ringwald #if   defined ( __CC_ARM )
34*6b8177c5SMatthias Ringwald   #include "cmsis_armcc.h"
35*6b8177c5SMatthias Ringwald 
36*6b8177c5SMatthias Ringwald 
37*6b8177c5SMatthias Ringwald /*
38*6b8177c5SMatthias Ringwald  * Arm Compiler 6.6 LTM (armclang)
39*6b8177c5SMatthias Ringwald  */
40*6b8177c5SMatthias Ringwald #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100)
41*6b8177c5SMatthias Ringwald   #include "cmsis_armclang_ltm.h"
42*6b8177c5SMatthias Ringwald 
43*6b8177c5SMatthias Ringwald   /*
44*6b8177c5SMatthias Ringwald  * Arm Compiler above 6.10.1 (armclang)
45*6b8177c5SMatthias Ringwald  */
46*6b8177c5SMatthias Ringwald #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
47*6b8177c5SMatthias Ringwald   #include "cmsis_armclang.h"
48*6b8177c5SMatthias Ringwald 
49*6b8177c5SMatthias Ringwald 
50*6b8177c5SMatthias Ringwald /*
51*6b8177c5SMatthias Ringwald  * GNU Compiler
52*6b8177c5SMatthias Ringwald  */
53*6b8177c5SMatthias Ringwald #elif defined ( __GNUC__ )
54*6b8177c5SMatthias Ringwald   #include "cmsis_gcc.h"
55*6b8177c5SMatthias Ringwald 
56*6b8177c5SMatthias Ringwald 
57*6b8177c5SMatthias Ringwald /*
58*6b8177c5SMatthias Ringwald  * IAR Compiler
59*6b8177c5SMatthias Ringwald  */
60*6b8177c5SMatthias Ringwald #elif defined ( __ICCARM__ )
61*6b8177c5SMatthias Ringwald   #include <cmsis_iccarm.h>
62*6b8177c5SMatthias Ringwald 
63*6b8177c5SMatthias Ringwald 
64*6b8177c5SMatthias Ringwald /*
65*6b8177c5SMatthias Ringwald  * TI Arm Compiler
66*6b8177c5SMatthias Ringwald  */
67*6b8177c5SMatthias Ringwald #elif defined ( __TI_ARM__ )
68*6b8177c5SMatthias Ringwald   #include <cmsis_ccs.h>
69*6b8177c5SMatthias Ringwald 
70*6b8177c5SMatthias Ringwald   #ifndef   __ASM
71*6b8177c5SMatthias Ringwald     #define __ASM                                  __asm
72*6b8177c5SMatthias Ringwald   #endif
73*6b8177c5SMatthias Ringwald   #ifndef   __INLINE
74*6b8177c5SMatthias Ringwald     #define __INLINE                               inline
75*6b8177c5SMatthias Ringwald   #endif
76*6b8177c5SMatthias Ringwald   #ifndef   __STATIC_INLINE
77*6b8177c5SMatthias Ringwald     #define __STATIC_INLINE                        static inline
78*6b8177c5SMatthias Ringwald   #endif
79*6b8177c5SMatthias Ringwald   #ifndef   __STATIC_FORCEINLINE
80*6b8177c5SMatthias Ringwald     #define __STATIC_FORCEINLINE                   __STATIC_INLINE
81*6b8177c5SMatthias Ringwald   #endif
82*6b8177c5SMatthias Ringwald   #ifndef   __NO_RETURN
83*6b8177c5SMatthias Ringwald     #define __NO_RETURN                            __attribute__((noreturn))
84*6b8177c5SMatthias Ringwald   #endif
85*6b8177c5SMatthias Ringwald   #ifndef   __USED
86*6b8177c5SMatthias Ringwald     #define __USED                                 __attribute__((used))
87*6b8177c5SMatthias Ringwald   #endif
88*6b8177c5SMatthias Ringwald   #ifndef   __WEAK
89*6b8177c5SMatthias Ringwald     #define __WEAK                                 __attribute__((weak))
90*6b8177c5SMatthias Ringwald   #endif
91*6b8177c5SMatthias Ringwald   #ifndef   __PACKED
92*6b8177c5SMatthias Ringwald     #define __PACKED                               __attribute__((packed))
93*6b8177c5SMatthias Ringwald   #endif
94*6b8177c5SMatthias Ringwald   #ifndef   __PACKED_STRUCT
95*6b8177c5SMatthias Ringwald     #define __PACKED_STRUCT                        struct __attribute__((packed))
96*6b8177c5SMatthias Ringwald   #endif
97*6b8177c5SMatthias Ringwald   #ifndef   __PACKED_UNION
98*6b8177c5SMatthias Ringwald     #define __PACKED_UNION                         union __attribute__((packed))
99*6b8177c5SMatthias Ringwald   #endif
100*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT32        /* deprecated */
101*6b8177c5SMatthias Ringwald     struct __attribute__((packed)) T_UINT32 { uint32_t v; };
102*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT32(x)                  (((struct T_UINT32 *)(x))->v)
103*6b8177c5SMatthias Ringwald   #endif
104*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT16_WRITE
105*6b8177c5SMatthias Ringwald     __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
106*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT16_WRITE(addr, val)    (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
107*6b8177c5SMatthias Ringwald   #endif
108*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT16_READ
109*6b8177c5SMatthias Ringwald     __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
110*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT16_READ(addr)          (((const struct T_UINT16_READ *)(const void *)(addr))->v)
111*6b8177c5SMatthias Ringwald   #endif
112*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT32_WRITE
113*6b8177c5SMatthias Ringwald     __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
114*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT32_WRITE(addr, val)    (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
115*6b8177c5SMatthias Ringwald   #endif
116*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT32_READ
117*6b8177c5SMatthias Ringwald     __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
118*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT32_READ(addr)          (((const struct T_UINT32_READ *)(const void *)(addr))->v)
119*6b8177c5SMatthias Ringwald   #endif
120*6b8177c5SMatthias Ringwald   #ifndef   __ALIGNED
121*6b8177c5SMatthias Ringwald     #define __ALIGNED(x)                           __attribute__((aligned(x)))
122*6b8177c5SMatthias Ringwald   #endif
123*6b8177c5SMatthias Ringwald   #ifndef   __RESTRICT
124*6b8177c5SMatthias Ringwald     #define __RESTRICT                             __restrict
125*6b8177c5SMatthias Ringwald   #endif
126*6b8177c5SMatthias Ringwald   #ifndef   __COMPILER_BARRIER
127*6b8177c5SMatthias Ringwald     #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
128*6b8177c5SMatthias Ringwald     #define __COMPILER_BARRIER()                   (void)0
129*6b8177c5SMatthias Ringwald   #endif
130*6b8177c5SMatthias Ringwald 
131*6b8177c5SMatthias Ringwald 
132*6b8177c5SMatthias Ringwald /*
133*6b8177c5SMatthias Ringwald  * TASKING Compiler
134*6b8177c5SMatthias Ringwald  */
135*6b8177c5SMatthias Ringwald #elif defined ( __TASKING__ )
136*6b8177c5SMatthias Ringwald   /*
137*6b8177c5SMatthias Ringwald    * The CMSIS functions have been implemented as intrinsics in the compiler.
138*6b8177c5SMatthias Ringwald    * Please use "carm -?i" to get an up to date list of all intrinsics,
139*6b8177c5SMatthias Ringwald    * Including the CMSIS ones.
140*6b8177c5SMatthias Ringwald    */
141*6b8177c5SMatthias Ringwald 
142*6b8177c5SMatthias Ringwald   #ifndef   __ASM
143*6b8177c5SMatthias Ringwald     #define __ASM                                  __asm
144*6b8177c5SMatthias Ringwald   #endif
145*6b8177c5SMatthias Ringwald   #ifndef   __INLINE
146*6b8177c5SMatthias Ringwald     #define __INLINE                               inline
147*6b8177c5SMatthias Ringwald   #endif
148*6b8177c5SMatthias Ringwald   #ifndef   __STATIC_INLINE
149*6b8177c5SMatthias Ringwald     #define __STATIC_INLINE                        static inline
150*6b8177c5SMatthias Ringwald   #endif
151*6b8177c5SMatthias Ringwald   #ifndef   __STATIC_FORCEINLINE
152*6b8177c5SMatthias Ringwald     #define __STATIC_FORCEINLINE                   __STATIC_INLINE
153*6b8177c5SMatthias Ringwald   #endif
154*6b8177c5SMatthias Ringwald   #ifndef   __NO_RETURN
155*6b8177c5SMatthias Ringwald     #define __NO_RETURN                            __attribute__((noreturn))
156*6b8177c5SMatthias Ringwald   #endif
157*6b8177c5SMatthias Ringwald   #ifndef   __USED
158*6b8177c5SMatthias Ringwald     #define __USED                                 __attribute__((used))
159*6b8177c5SMatthias Ringwald   #endif
160*6b8177c5SMatthias Ringwald   #ifndef   __WEAK
161*6b8177c5SMatthias Ringwald     #define __WEAK                                 __attribute__((weak))
162*6b8177c5SMatthias Ringwald   #endif
163*6b8177c5SMatthias Ringwald   #ifndef   __PACKED
164*6b8177c5SMatthias Ringwald     #define __PACKED                               __packed__
165*6b8177c5SMatthias Ringwald   #endif
166*6b8177c5SMatthias Ringwald   #ifndef   __PACKED_STRUCT
167*6b8177c5SMatthias Ringwald     #define __PACKED_STRUCT                        struct __packed__
168*6b8177c5SMatthias Ringwald   #endif
169*6b8177c5SMatthias Ringwald   #ifndef   __PACKED_UNION
170*6b8177c5SMatthias Ringwald     #define __PACKED_UNION                         union __packed__
171*6b8177c5SMatthias Ringwald   #endif
172*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT32        /* deprecated */
173*6b8177c5SMatthias Ringwald     struct __packed__ T_UINT32 { uint32_t v; };
174*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT32(x)                  (((struct T_UINT32 *)(x))->v)
175*6b8177c5SMatthias Ringwald   #endif
176*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT16_WRITE
177*6b8177c5SMatthias Ringwald     __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
178*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT16_WRITE(addr, val)    (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
179*6b8177c5SMatthias Ringwald   #endif
180*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT16_READ
181*6b8177c5SMatthias Ringwald     __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
182*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT16_READ(addr)          (((const struct T_UINT16_READ *)(const void *)(addr))->v)
183*6b8177c5SMatthias Ringwald   #endif
184*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT32_WRITE
185*6b8177c5SMatthias Ringwald     __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
186*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT32_WRITE(addr, val)    (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
187*6b8177c5SMatthias Ringwald   #endif
188*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT32_READ
189*6b8177c5SMatthias Ringwald     __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
190*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT32_READ(addr)          (((const struct T_UINT32_READ *)(const void *)(addr))->v)
191*6b8177c5SMatthias Ringwald   #endif
192*6b8177c5SMatthias Ringwald   #ifndef   __ALIGNED
193*6b8177c5SMatthias Ringwald     #define __ALIGNED(x)              __align(x)
194*6b8177c5SMatthias Ringwald   #endif
195*6b8177c5SMatthias Ringwald   #ifndef   __RESTRICT
196*6b8177c5SMatthias Ringwald     #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
197*6b8177c5SMatthias Ringwald     #define __RESTRICT
198*6b8177c5SMatthias Ringwald   #endif
199*6b8177c5SMatthias Ringwald   #ifndef   __COMPILER_BARRIER
200*6b8177c5SMatthias Ringwald     #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
201*6b8177c5SMatthias Ringwald     #define __COMPILER_BARRIER()                   (void)0
202*6b8177c5SMatthias Ringwald   #endif
203*6b8177c5SMatthias Ringwald 
204*6b8177c5SMatthias Ringwald 
205*6b8177c5SMatthias Ringwald /*
206*6b8177c5SMatthias Ringwald  * COSMIC Compiler
207*6b8177c5SMatthias Ringwald  */
208*6b8177c5SMatthias Ringwald #elif defined ( __CSMC__ )
209*6b8177c5SMatthias Ringwald    #include <cmsis_csm.h>
210*6b8177c5SMatthias Ringwald 
211*6b8177c5SMatthias Ringwald  #ifndef   __ASM
212*6b8177c5SMatthias Ringwald     #define __ASM                                  _asm
213*6b8177c5SMatthias Ringwald   #endif
214*6b8177c5SMatthias Ringwald   #ifndef   __INLINE
215*6b8177c5SMatthias Ringwald     #define __INLINE                               inline
216*6b8177c5SMatthias Ringwald   #endif
217*6b8177c5SMatthias Ringwald   #ifndef   __STATIC_INLINE
218*6b8177c5SMatthias Ringwald     #define __STATIC_INLINE                        static inline
219*6b8177c5SMatthias Ringwald   #endif
220*6b8177c5SMatthias Ringwald   #ifndef   __STATIC_FORCEINLINE
221*6b8177c5SMatthias Ringwald     #define __STATIC_FORCEINLINE                   __STATIC_INLINE
222*6b8177c5SMatthias Ringwald   #endif
223*6b8177c5SMatthias Ringwald   #ifndef   __NO_RETURN
224*6b8177c5SMatthias Ringwald     // NO RETURN is automatically detected hence no warning here
225*6b8177c5SMatthias Ringwald     #define __NO_RETURN
226*6b8177c5SMatthias Ringwald   #endif
227*6b8177c5SMatthias Ringwald   #ifndef   __USED
228*6b8177c5SMatthias Ringwald     #warning No compiler specific solution for __USED. __USED is ignored.
229*6b8177c5SMatthias Ringwald     #define __USED
230*6b8177c5SMatthias Ringwald   #endif
231*6b8177c5SMatthias Ringwald   #ifndef   __WEAK
232*6b8177c5SMatthias Ringwald     #define __WEAK                                 __weak
233*6b8177c5SMatthias Ringwald   #endif
234*6b8177c5SMatthias Ringwald   #ifndef   __PACKED
235*6b8177c5SMatthias Ringwald     #define __PACKED                               @packed
236*6b8177c5SMatthias Ringwald   #endif
237*6b8177c5SMatthias Ringwald   #ifndef   __PACKED_STRUCT
238*6b8177c5SMatthias Ringwald     #define __PACKED_STRUCT                        @packed struct
239*6b8177c5SMatthias Ringwald   #endif
240*6b8177c5SMatthias Ringwald   #ifndef   __PACKED_UNION
241*6b8177c5SMatthias Ringwald     #define __PACKED_UNION                         @packed union
242*6b8177c5SMatthias Ringwald   #endif
243*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT32        /* deprecated */
244*6b8177c5SMatthias Ringwald     @packed struct T_UINT32 { uint32_t v; };
245*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT32(x)                  (((struct T_UINT32 *)(x))->v)
246*6b8177c5SMatthias Ringwald   #endif
247*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT16_WRITE
248*6b8177c5SMatthias Ringwald     __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
249*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT16_WRITE(addr, val)    (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
250*6b8177c5SMatthias Ringwald   #endif
251*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT16_READ
252*6b8177c5SMatthias Ringwald     __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
253*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT16_READ(addr)          (((const struct T_UINT16_READ *)(const void *)(addr))->v)
254*6b8177c5SMatthias Ringwald   #endif
255*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT32_WRITE
256*6b8177c5SMatthias Ringwald     __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
257*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT32_WRITE(addr, val)    (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
258*6b8177c5SMatthias Ringwald   #endif
259*6b8177c5SMatthias Ringwald   #ifndef   __UNALIGNED_UINT32_READ
260*6b8177c5SMatthias Ringwald     __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
261*6b8177c5SMatthias Ringwald     #define __UNALIGNED_UINT32_READ(addr)          (((const struct T_UINT32_READ *)(const void *)(addr))->v)
262*6b8177c5SMatthias Ringwald   #endif
263*6b8177c5SMatthias Ringwald   #ifndef   __ALIGNED
264*6b8177c5SMatthias Ringwald     #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
265*6b8177c5SMatthias Ringwald     #define __ALIGNED(x)
266*6b8177c5SMatthias Ringwald   #endif
267*6b8177c5SMatthias Ringwald   #ifndef   __RESTRICT
268*6b8177c5SMatthias Ringwald     #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
269*6b8177c5SMatthias Ringwald     #define __RESTRICT
270*6b8177c5SMatthias Ringwald   #endif
271*6b8177c5SMatthias Ringwald   #ifndef   __COMPILER_BARRIER
272*6b8177c5SMatthias Ringwald     #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
273*6b8177c5SMatthias Ringwald     #define __COMPILER_BARRIER()                   (void)0
274*6b8177c5SMatthias Ringwald   #endif
275*6b8177c5SMatthias Ringwald 
276*6b8177c5SMatthias Ringwald 
277*6b8177c5SMatthias Ringwald #else
278*6b8177c5SMatthias Ringwald   #error Unknown compiler.
279*6b8177c5SMatthias Ringwald #endif
280*6b8177c5SMatthias Ringwald 
281*6b8177c5SMatthias Ringwald 
282*6b8177c5SMatthias Ringwald #endif /* __CMSIS_COMPILER_H */
283*6b8177c5SMatthias Ringwald 
284