]> begriffs open source - cmsis/blob - CMSIS/Core/Include/cmsis_compiler.h
CMSIS_Core:
[cmsis] / CMSIS / Core / Include / cmsis_compiler.h
1 /**************************************************************************//**
2  * @file     cmsis_compiler.h
3  * @brief    CMSIS compiler specific macros, functions, instructions
4  * @version  V5.00
5  * @date     24. August 2016
6  ******************************************************************************/
7 /*
8  * Copyright (c) 2009-2016 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  * http://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   #ifndef   __ASM
56     #define __ASM                     __asm
57   #endif
58   #ifndef   __INLINE
59     #define __INLINE                  inline
60   #endif
61   #ifndef   __STATIC_INLINE
62     #define __STATIC_INLINE           static inline
63   #endif
64   #ifndef   __NO_RETURN
65     #define __NO_RETURN               __noreturn
66   #endif
67   #ifndef   __USED
68     #warning No compiler specific solution for __USED. __USED is ignored.
69     #define __USED
70   #endif
71   #ifndef   __WEAK
72     #define __WEAK                    __weak
73   #endif
74   #ifndef   __UNALIGNED_UINT32
75     __packed struct T_UINT32 { uint32_t v; };
76       #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)
77   #endif
78   #ifndef   __ALIGNED
79     #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
80     #define __ALIGNED(x)
81   #endif
82   #ifndef   __PACKED
83     #define __PACKED                  __packed
84   #endif
85
86   #include <cmsis_iar.h>
87
88
89 /*
90  * TI ARM Compiler
91  */
92 #elif defined ( __TI_ARM__ )
93   #ifndef   __ASM
94     #define __ASM                     __asm
95   #endif
96   #ifndef   __INLINE
97     #define __INLINE                  inline
98   #endif
99   #ifndef   __STATIC_INLINE
100     #define __STATIC_INLINE           static inline
101   #endif
102   #ifndef   __NO_RETURN
103     #define __NO_RETURN               __attribute__((noreturn))
104   #endif
105   #ifndef   __USED
106     #define __USED                    __attribute__((used))
107   #endif
108   #ifndef   __WEAK
109     #define __WEAK                    __attribute__((weak))
110   #endif
111   #ifndef   __UNALIGNED_UINT32
112     struct __attribute__((packed)) T_UINT32 { uint32_t v; };
113     #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)
114   #endif
115   #ifndef   __ALIGNED
116     #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
117     #define __ALIGNED(x)
118   #endif
119   #ifndef   __PACKED
120     #define __PACKED                  __attribute__((packed))
121   #endif
122
123   #include <cmsis_ccs.h>
124
125
126 /*
127  * TASKING Compiler
128  */
129 #elif defined ( __TASKING__ )
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   __UNALIGNED_UINT32
149     struct __packed__ T_UINT32 { uint32_t v; };
150     #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)
151   #endif
152   #ifndef   __ALIGNED
153     #define __ALIGNED(x)              __align(x)
154   #endif
155   #ifndef   __PACKED
156     #define __PACKED                  __packed__
157   #endif
158
159   /*
160    * The CMSIS functions have been implemented as intrinsics in the compiler.
161    * Please use "carm -?i" to get an up to date list of all intrinsics,
162    * Including the CMSIS ones.
163    */
164
165
166 /*
167  * COSMIC Compiler
168  */
169 #elif defined ( __CSMC__ )
170   #ifndef   __ASM
171     #define __ASM                     _asm
172   #endif
173   #ifndef   __INLINE
174     #define __INLINE                  inline
175   #endif
176   #ifndef   __STATIC_INLINE
177     #define __STATIC_INLINE           static inline
178   #endif
179   #ifndef   __NO_RETURN
180     #warning No compiler specific solution for __NO_RETURN. __NO_RETURN is ignored.
181     #define __NO_RETURN
182   #endif
183   #ifndef   __USED
184     #warning No compiler specific solution for __USED. __USED is ignored.
185     #define __USED
186   #endif
187   #ifndef   __WEAK
188     #warning No compiler specific solution for __WEAK. __WEAK is ignored.
189     #define __WEAK
190   #endif
191   #ifndef   __UNALIGNED_UINT32
192     #warning No compiler specific solution for __UNALIGNED_UINT32. __UNALIGNED_UINT32 is ignored.
193     #define __UNALIGNED_UINT32(x)     (*x)
194   #endif
195   #ifndef   __ALIGNED
196     #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
197     #define __ALIGNED(x)
198   #endif
199   #ifndef   __PACKED
200     #warning No compiler specific solution for __PACKED. __PACKED is ignored.
201     #define __PACKED
202   #endif
203
204   #include <cmsis_csm.h>
205
206
207 #else
208   #error Unknown compiler.
209 #endif
210
211
212 #endif /* __CMSIS_COMPILER_H */
213