]> begriffs open source - cmsis/blob - CMSIS/Core_A/Include/cmsis_compiler.h
Added typecasts to __REVSH
[cmsis] / CMSIS / Core_A / Include / cmsis_compiler.h
1 /**************************************************************************//**
2  * @file     cmsis_compiler.h
3  * @brief    CMSIS compiler specific macros, functions, instructions
4  * @version  V1.00
5  * @date     22. Feb 2017
6  ******************************************************************************/
7 /*
8  * Copyright (c) 2009-2017 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   __NO_RETURN
74     #define __NO_RETURN               __attribute__((noreturn))
75   #endif
76   #ifndef   __USED
77     #define __USED                    __attribute__((used))
78   #endif
79   #ifndef   __WEAK
80     #define __WEAK                    __attribute__((weak))
81   #endif
82   #ifndef   __UNALIGNED_UINT32
83     struct __attribute__((packed)) T_UINT32 { uint32_t v; };
84     #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)
85   #endif
86   #ifndef   __ALIGNED
87     #define __ALIGNED(x)              __attribute__((aligned(x)))
88   #endif
89   #ifndef   __PACKED
90     #define __PACKED                  __attribute__((packed))
91   #endif
92
93
94 /*
95  * TASKING Compiler
96  */
97 #elif defined ( __TASKING__ )
98   /*
99    * The CMSIS functions have been implemented as intrinsics in the compiler.
100    * Please use "carm -?i" to get an up to date list of all intrinsics,
101    * Including the CMSIS ones.
102    */
103
104   #ifndef   __ASM
105     #define __ASM                     __asm
106   #endif
107   #ifndef   __INLINE
108     #define __INLINE                  inline
109   #endif
110   #ifndef   __STATIC_INLINE
111     #define __STATIC_INLINE           static inline
112   #endif
113   #ifndef   __NO_RETURN
114     #define __NO_RETURN               __attribute__((noreturn))
115   #endif
116   #ifndef   __USED
117     #define __USED                    __attribute__((used))
118   #endif
119   #ifndef   __WEAK
120     #define __WEAK                    __attribute__((weak))
121   #endif
122   #ifndef   __UNALIGNED_UINT32
123     struct __packed__ T_UINT32 { uint32_t v; };
124     #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)
125   #endif
126   #ifndef   __ALIGNED
127     #define __ALIGNED(x)              __align(x)
128   #endif
129   #ifndef   __PACKED
130     #define __PACKED                  __packed__
131   #endif
132
133
134 /*
135  * COSMIC Compiler
136  */
137 #elif defined ( __CSMC__ )
138    #include <cmsis_csm.h>
139
140  #ifndef   __ASM
141     #define __ASM                     _asm
142   #endif
143   #ifndef   __INLINE
144     #define __INLINE                  inline
145   #endif
146   #ifndef   __STATIC_INLINE
147     #define __STATIC_INLINE           static inline
148   #endif
149   #ifndef   __NO_RETURN
150     // NO RETURN is automatically detected hence no warning here
151     #define __NO_RETURN
152   #endif
153   #ifndef   __USED
154     #warning No compiler specific solution for __USED. __USED is ignored.
155     #define __USED
156   #endif
157   #ifndef   __WEAK
158     #define __WEAK                    __weak
159   #endif
160   #ifndef   __UNALIGNED_UINT32
161     @packed struct T_UINT32 { uint32_t v; };
162     #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)
163   #endif
164   #ifndef   __ALIGNED
165     #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
166     #define __ALIGNED(x)
167   #endif
168   #ifndef   __PACKED
169     #define __PACKED                  @packed
170   #endif
171
172
173 #else
174   #error Unknown compiler.
175 #endif
176
177
178 #endif /* __CMSIS_COMPILER_H */
179