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