]> begriffs open source - cmsis/blob - CMSIS/Core/Include/cmsis_compiler.h
Updated cmsis_compiler.h to fix IAR CMSIS macro problem.
[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     09. November 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
56   #ifndef   __ASM
57     #define __ASM                     __asm
58   #endif
59   #ifndef   __INLINE
60     #define __INLINE                  inline
61   #endif
62   #ifndef   __STATIC_INLINE
63     #define __STATIC_INLINE           static inline
64   #endif
65
66   #include <cmsis_iar.h>
67
68   #ifndef   __NO_RETURN
69     #define __NO_RETURN               __noreturn
70   #endif
71   #ifndef   __USED
72     #define __USED                    __root
73   #endif
74   #ifndef   __WEAK
75     #define __WEAK                    __weak
76   #endif
77   #ifndef   __UNALIGNED_UINT32
78     __packed struct T_UINT32 { uint32_t v; };
79       #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)
80   #endif
81   #ifndef   __ALIGNED
82     #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
83     #define __ALIGNED(x)
84   #endif
85   #ifndef   __PACKED
86     #define __PACKED                  __packed
87   #endif
88
89
90 /*
91  * TI ARM Compiler
92  */
93 #elif defined ( __TI_ARM__ )
94   #include <cmsis_ccs.h>
95
96   #ifndef   __ASM
97     #define __ASM                     __asm
98   #endif
99   #ifndef   __INLINE
100     #define __INLINE                  inline
101   #endif
102   #ifndef   __STATIC_INLINE
103     #define __STATIC_INLINE           static inline
104   #endif
105   #ifndef   __NO_RETURN
106     #define __NO_RETURN               __attribute__((noreturn))
107   #endif
108   #ifndef   __USED
109     #define __USED                    __attribute__((used))
110   #endif
111   #ifndef   __WEAK
112     #define __WEAK                    __attribute__((weak))
113   #endif
114   #ifndef   __UNALIGNED_UINT32
115     struct __attribute__((packed)) T_UINT32 { uint32_t v; };
116     #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)
117   #endif
118   #ifndef   __ALIGNED
119     #define __ALIGNED(x)              __attribute__((aligned(x)))
120   #endif
121   #ifndef   __PACKED
122     #define __PACKED                  __attribute__((packed))
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   __NO_RETURN
146     #define __NO_RETURN               __attribute__((noreturn))
147   #endif
148   #ifndef   __USED
149     #define __USED                    __attribute__((used))
150   #endif
151   #ifndef   __WEAK
152     #define __WEAK                    __attribute__((weak))
153   #endif
154   #ifndef   __UNALIGNED_UINT32
155     struct __packed__ T_UINT32 { uint32_t v; };
156     #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)
157   #endif
158   #ifndef   __ALIGNED
159     #define __ALIGNED(x)              __align(x)
160   #endif
161   #ifndef   __PACKED
162     #define __PACKED                  __packed__
163   #endif
164
165
166 /*
167  * COSMIC Compiler
168  */
169 #elif defined ( __CSMC__ )
170    #include <cmsis_csm.h>
171
172  #ifndef   __ASM
173     #define __ASM                     _asm
174   #endif
175   #ifndef   __INLINE
176     #define __INLINE                  inline
177   #endif
178   #ifndef   __STATIC_INLINE
179     #define __STATIC_INLINE           static inline
180   #endif
181   #ifndef   __NO_RETURN
182     // NO RETURN is automatically detected hence no warning here
183     #define __NO_RETURN
184   #endif
185   #ifndef   __USED
186     #warning No compiler specific solution for __USED. __USED is ignored.
187     #define __USED
188   #endif
189   #ifndef   __WEAK
190     #define __WEAK                    __weak
191   #endif
192   #ifndef   __UNALIGNED_UINT32
193     @packed struct T_UINT32 { uint32_t v; };
194     #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)
195   #endif
196   #ifndef   __ALIGNED
197     #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
198     #define __ALIGNED(x)
199   #endif
200   #ifndef   __PACKED
201     #define __PACKED                  @packed
202   #endif
203
204
205 #else
206   #error Unknown compiler.
207 #endif
208
209
210 #endif /* __CMSIS_COMPILER_H */
211