]> begriffs open source - cmsis/blob - CMSIS/Core/Include/cmsis_compiler.h
Updated cmsis_compiler.h
[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     01. September 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   #include <cmsis_iar.h>
56
57   #ifndef   __ASM
58     #define __ASM                     __asm
59   #endif
60   #ifndef   __INLINE
61     #define __INLINE                  inline
62   #endif
63   #ifndef   __STATIC_INLINE
64     #define __STATIC_INLINE           static inline
65   #endif
66   #ifndef   __NO_RETURN
67     #define __NO_RETURN               __noreturn
68   #endif
69   #ifndef   __USED
70     #define __USED                    __root
71   #endif
72   #ifndef   __WEAK
73     #define __WEAK                    __weak
74   #endif
75   #ifndef   __UNALIGNED_UINT32
76     __packed struct T_UINT32 { uint32_t v; };
77       #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)
78   #endif
79   #ifndef   __ALIGNED
80     #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
81     #define __ALIGNED(x)
82   #endif
83   #ifndef   __PACKED
84     #define __PACKED                  __packed
85   #endif
86
87
88 /*
89  * TI ARM Compiler
90  */
91 #elif defined ( __TI_ARM__ )
92   #include <cmsis_ccs.h>
93
94   #ifndef   __ASM
95     #define __ASM                     __asm
96   #endif
97   #ifndef   __INLINE
98     #define __INLINE                  inline
99   #endif
100   #ifndef   __STATIC_INLINE
101     #define __STATIC_INLINE           static inline
102   #endif
103   #ifndef   __NO_RETURN
104     #define __NO_RETURN               __attribute__((noreturn))
105   #endif
106   #ifndef   __USED
107     #define __USED                    __attribute__((used))
108   #endif
109   #ifndef   __WEAK
110     #define __WEAK                    __attribute__((weak))
111   #endif
112   #ifndef   __UNALIGNED_UINT32
113     struct __attribute__((packed)) T_UINT32 { uint32_t v; };
114     #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)
115   #endif
116   #ifndef   __ALIGNED
117     #define __ALIGNED(x)              __attribute__((aligned(x)))
118   #endif
119   #ifndef   __PACKED
120     #define __PACKED                  __attribute__((packed))
121   #endif
122
123
124 /*
125  * TASKING Compiler
126  */
127 #elif defined ( __TASKING__ )
128   /*
129    * The CMSIS functions have been implemented as intrinsics in the compiler.
130    * Please use "carm -?i" to get an up to date list of all intrinsics,
131    * Including the CMSIS ones.
132    */
133
134   #ifndef   __ASM
135     #define __ASM                     __asm
136   #endif
137   #ifndef   __INLINE
138     #define __INLINE                  inline
139   #endif
140   #ifndef   __STATIC_INLINE
141     #define __STATIC_INLINE           static inline
142   #endif
143   #ifndef   __NO_RETURN
144     #define __NO_RETURN               __attribute__((noreturn))
145   #endif
146   #ifndef   __USED
147     #define __USED                    __attribute__((used))
148   #endif
149   #ifndef   __WEAK
150     #define __WEAK                    __attribute__((weak))
151   #endif
152   #ifndef   __UNALIGNED_UINT32
153     struct __packed__ T_UINT32 { uint32_t v; };
154     #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)
155   #endif
156   #ifndef   __ALIGNED
157     #define __ALIGNED(x)              __align(x)
158   #endif
159   #ifndef   __PACKED
160     #define __PACKED                  __packed__
161   #endif
162
163
164 /*
165  * COSMIC Compiler
166  */
167 #elif defined ( __CSMC__ )
168    #include <cmsis_csm.h>
169
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
205 #else
206   #error Unknown compiler.
207 #endif
208
209
210 #endif /* __CMSIS_COMPILER_H */
211