]> begriffs open source - cmsis/blob - CMSIS/Core/Include/cmsis_compiler.h
Core(M): Fixed core_cm33.h DSP usage detection based on ACLE predefined macro __ARM_F...
[cmsis] / CMSIS / Core / Include / cmsis_compiler.h
1 /**************************************************************************//**
2  * @file     cmsis_compiler.h
3  * @brief    CMSIS compiler generic header file
4  * @version  V5.0.2
5  * @date     13. February 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   #include <cmsis_iccarm.h>
56
57   
58 /*
59  * TI ARM Compiler
60  */
61 #elif defined ( __TI_ARM__ )
62   #include <cmsis_ccs.h>
63
64   #ifndef   __ASM
65     #define __ASM                                  __asm
66   #endif
67   #ifndef   __INLINE
68     #define __INLINE                               inline
69   #endif
70   #ifndef   __STATIC_INLINE
71     #define __STATIC_INLINE                        static inline
72   #endif
73   #ifndef   __NO_RETURN
74     #define __NO_RETURN                            __attribute__((noreturn))
75   #endif
76   #ifndef   __USED
77     #define __USED                                 __attribute__((used))
78   #endif
79   #ifndef   __WEAK
80     #define __WEAK                                 __attribute__((weak))
81   #endif
82   #ifndef   __PACKED
83     #define __PACKED                               __attribute__((packed))
84   #endif
85   #ifndef   __PACKED_STRUCT
86     #define __PACKED_STRUCT                        struct __attribute__((packed))
87   #endif
88   #ifndef   __PACKED_UNION
89     #define __PACKED_UNION                         union __attribute__((packed))
90   #endif
91   #ifndef   __UNALIGNED_UINT32        /* deprecated */
92     struct __attribute__((packed)) T_UINT32 { uint32_t v; };
93     #define __UNALIGNED_UINT32(x)                  (((struct T_UINT32 *)(x))->v)
94   #endif
95   #ifndef   __UNALIGNED_UINT16_WRITE
96     __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
97     #define __UNALIGNED_UINT16_WRITE(addr, val)    (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
98   #endif
99   #ifndef   __UNALIGNED_UINT16_READ
100     __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
101     #define __UNALIGNED_UINT16_READ(addr)          (((const struct T_UINT16_READ *)(const void *)(addr))->v)
102   #endif
103   #ifndef   __UNALIGNED_UINT32_WRITE
104     __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
105     #define __UNALIGNED_UINT32_WRITE(addr, val)    (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
106   #endif
107   #ifndef   __UNALIGNED_UINT32_READ
108     __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
109     #define __UNALIGNED_UINT32_READ(addr)          (((const struct T_UINT32_READ *)(const void *)(addr))->v)
110   #endif
111   #ifndef   __ALIGNED
112     #define __ALIGNED(x)                           __attribute__((aligned(x)))
113   #endif
114   #ifndef   __RESTRICT
115     #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
116     #define __RESTRICT
117   #endif
118
119
120 /*
121  * TASKING Compiler
122  */
123 #elif defined ( __TASKING__ )
124   /*
125    * The CMSIS functions have been implemented as intrinsics in the compiler.
126    * Please use "carm -?i" to get an up to date list of all intrinsics,
127    * Including the CMSIS ones.
128    */
129
130   #ifndef   __ASM
131     #define __ASM                                  __asm
132   #endif
133   #ifndef   __INLINE
134     #define __INLINE                               inline
135   #endif
136   #ifndef   __STATIC_INLINE
137     #define __STATIC_INLINE                        static inline
138   #endif
139   #ifndef   __NO_RETURN
140     #define __NO_RETURN                            __attribute__((noreturn))
141   #endif
142   #ifndef   __USED
143     #define __USED                                 __attribute__((used))
144   #endif
145   #ifndef   __WEAK
146     #define __WEAK                                 __attribute__((weak))
147   #endif
148   #ifndef   __PACKED
149     #define __PACKED                               __packed__
150   #endif
151   #ifndef   __PACKED_STRUCT
152     #define __PACKED_STRUCT                        struct __packed__
153   #endif
154   #ifndef   __PACKED_UNION
155     #define __PACKED_UNION                         union __packed__
156   #endif
157   #ifndef   __UNALIGNED_UINT32        /* deprecated */
158     struct __packed__ T_UINT32 { uint32_t v; };
159     #define __UNALIGNED_UINT32(x)                  (((struct T_UINT32 *)(x))->v)
160   #endif
161   #ifndef   __UNALIGNED_UINT16_WRITE
162     __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
163     #define __UNALIGNED_UINT16_WRITE(addr, val)    (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
164   #endif
165   #ifndef   __UNALIGNED_UINT16_READ
166     __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
167     #define __UNALIGNED_UINT16_READ(addr)          (((const struct T_UINT16_READ *)(const void *)(addr))->v)
168   #endif
169   #ifndef   __UNALIGNED_UINT32_WRITE
170     __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
171     #define __UNALIGNED_UINT32_WRITE(addr, val)    (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
172   #endif
173   #ifndef   __UNALIGNED_UINT32_READ
174     __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
175     #define __UNALIGNED_UINT32_READ(addr)          (((const struct T_UINT32_READ *)(const void *)(addr))->v)
176   #endif
177   #ifndef   __ALIGNED
178     #define __ALIGNED(x)              __align(x)
179   #endif
180   #ifndef   __RESTRICT
181     #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
182     #define __RESTRICT
183   #endif
184
185
186 /*
187  * COSMIC Compiler
188  */
189 #elif defined ( __CSMC__ )
190    #include <cmsis_csm.h>
191
192  #ifndef   __ASM
193     #define __ASM                                  _asm
194   #endif
195   #ifndef   __INLINE
196     #define __INLINE                               inline
197   #endif
198   #ifndef   __STATIC_INLINE
199     #define __STATIC_INLINE                        static inline
200   #endif
201   #ifndef   __NO_RETURN
202     // NO RETURN is automatically detected hence no warning here
203     #define __NO_RETURN
204   #endif
205   #ifndef   __USED
206     #warning No compiler specific solution for __USED. __USED is ignored.
207     #define __USED
208   #endif
209   #ifndef   __WEAK
210     #define __WEAK                                 __weak
211   #endif
212   #ifndef   __PACKED
213     #define __PACKED                               @packed
214   #endif
215   #ifndef   __PACKED_STRUCT
216     #define __PACKED_STRUCT                        @packed struct
217   #endif
218   #ifndef   __PACKED_UNION
219     #define __PACKED_UNION                         @packed union
220   #endif
221   #ifndef   __UNALIGNED_UINT32        /* deprecated */
222     @packed struct T_UINT32 { uint32_t v; };
223     #define __UNALIGNED_UINT32(x)                  (((struct T_UINT32 *)(x))->v)
224   #endif
225   #ifndef   __UNALIGNED_UINT16_WRITE
226     __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
227     #define __UNALIGNED_UINT16_WRITE(addr, val)    (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
228   #endif
229   #ifndef   __UNALIGNED_UINT16_READ
230     __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
231     #define __UNALIGNED_UINT16_READ(addr)          (((const struct T_UINT16_READ *)(const void *)(addr))->v)
232   #endif
233   #ifndef   __UNALIGNED_UINT32_WRITE
234     __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
235     #define __UNALIGNED_UINT32_WRITE(addr, val)    (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
236   #endif
237   #ifndef   __UNALIGNED_UINT32_READ
238     __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
239     #define __UNALIGNED_UINT32_READ(addr)          (((const struct T_UINT32_READ *)(const void *)(addr))->v)
240   #endif
241   #ifndef   __ALIGNED
242     #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
243     #define __ALIGNED(x)
244   #endif
245   #ifndef   __RESTRICT
246     #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
247     #define __RESTRICT
248   #endif
249
250
251 #else
252   #error Unknown compiler.
253 #endif
254
255
256 #endif /* __CMSIS_COMPILER_H */
257