]> begriffs open source - cmsis/blob - CMSIS/Core/Include/cmsis_compiler.h
Updated CMSIS macros for TI compiler.
[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     25. 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     #define __ALIGNED(x)              __attribute__((aligned(x)))
117   #endif
118   #ifndef   __PACKED
119     #define __PACKED                  __attribute__((packed))
120   #endif
121
122   #include <cmsis_ccs.h>
123
124
125 /*
126  * TASKING Compiler
127  */
128 #elif defined ( __TASKING__ )
129   #ifndef   __ASM
130     #define __ASM                     __asm
131   #endif
132   #ifndef   __INLINE
133     #define __INLINE                  inline
134   #endif
135   #ifndef   __STATIC_INLINE
136     #define __STATIC_INLINE           static inline
137   #endif
138   #ifndef   __NO_RETURN
139     #define __NO_RETURN               __attribute__((noreturn))
140   #endif
141   #ifndef   __USED
142     #define __USED                    __attribute__((used))
143   #endif
144   #ifndef   __WEAK
145     #define __WEAK                    __attribute__((weak))
146   #endif
147   #ifndef   __UNALIGNED_UINT32
148     struct __packed__ T_UINT32 { uint32_t v; };
149     #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)
150   #endif
151   #ifndef   __ALIGNED
152     #define __ALIGNED(x)              __align(x)
153   #endif
154   #ifndef   __PACKED
155     #define __PACKED                  __packed__
156   #endif
157
158   /*
159    * The CMSIS functions have been implemented as intrinsics in the compiler.
160    * Please use "carm -?i" to get an up to date list of all intrinsics,
161    * Including the CMSIS ones.
162    */
163
164
165 /*
166  * COSMIC Compiler
167  */
168 #elif defined ( __CSMC__ )
169   #ifndef   __ASM
170     #define __ASM                     _asm
171   #endif
172   #ifndef   __INLINE
173     #define __INLINE                  inline
174   #endif
175   #ifndef   __STATIC_INLINE
176     #define __STATIC_INLINE           static inline
177   #endif
178   #ifndef   __NO_RETURN
179     #warning No compiler specific solution for __NO_RETURN. __NO_RETURN is ignored.
180     #define __NO_RETURN
181   #endif
182   #ifndef   __USED
183     #warning No compiler specific solution for __USED. __USED is ignored.
184     #define __USED
185   #endif
186   #ifndef   __WEAK
187     #warning No compiler specific solution for __WEAK. __WEAK is ignored.
188     #define __WEAK
189   #endif
190   #ifndef   __UNALIGNED_UINT32
191     #warning No compiler specific solution for __UNALIGNED_UINT32. __UNALIGNED_UINT32 is ignored.
192     #define __UNALIGNED_UINT32(x)     (*x)
193   #endif
194   #ifndef   __ALIGNED
195     #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
196     #define __ALIGNED(x)
197   #endif
198   #ifndef   __PACKED
199     #warning No compiler specific solution for __PACKED. __PACKED is ignored.
200     #define __PACKED
201   #endif
202
203   #include <cmsis_csm.h>
204
205
206 #else
207   #error Unknown compiler.
208 #endif
209
210
211 #endif /* __CMSIS_COMPILER_H */
212