Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
cmsis_compiler.h
00001 /**************************************************************************//** 00002 * @file cmsis_compiler.h 00003 * @brief CMSIS compiler generic header file 00004 * @version V5.1.0 00005 * @date 09. October 2018 00006 ******************************************************************************/ 00007 /* 00008 * Copyright (c) 2009-2018 Arm Limited. All rights reserved. 00009 * 00010 * SPDX-License-Identifier: Apache-2.0 00011 * 00012 * Licensed under the Apache License, Version 2.0 (the License); you may 00013 * not use this file except in compliance with the License. 00014 * You may obtain a copy of the License at 00015 * 00016 * www.apache.org/licenses/LICENSE-2.0 00017 * 00018 * Unless required by applicable law or agreed to in writing, software 00019 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00020 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00021 * See the License for the specific language governing permissions and 00022 * limitations under the License. 00023 */ 00024 00025 #ifndef __CMSIS_COMPILER_H 00026 #define __CMSIS_COMPILER_H 00027 00028 #include <stdint.h> 00029 00030 /* 00031 * Arm Compiler 4/5 00032 */ 00033 #if defined ( __CC_ARM ) 00034 #include "cmsis_armcc.h" 00035 00036 00037 /* 00038 * Arm Compiler 6.6 LTM (armclang) 00039 */ 00040 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100) 00041 #include "cmsis_armclang_ltm.h" 00042 00043 /* 00044 * Arm Compiler above 6.10.1 (armclang) 00045 */ 00046 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100) 00047 #include "cmsis_armclang.h" 00048 00049 00050 /* 00051 * GNU Compiler 00052 */ 00053 #elif defined ( __GNUC__ ) 00054 #include "cmsis_gcc.h" 00055 00056 00057 /* 00058 * IAR Compiler 00059 */ 00060 #elif defined ( __ICCARM__ ) 00061 #include <cmsis_iccarm.h> 00062 00063 00064 /* 00065 * TI Arm Compiler 00066 */ 00067 #elif defined ( __TI_ARM__ ) 00068 #include <cmsis_ccs.h> 00069 00070 #ifndef __ASM 00071 #define __ASM __asm 00072 #endif 00073 #ifndef __INLINE 00074 #define __INLINE inline 00075 #endif 00076 #ifndef __STATIC_INLINE 00077 #define __STATIC_INLINE static inline 00078 #endif 00079 #ifndef __STATIC_FORCEINLINE 00080 #define __STATIC_FORCEINLINE __STATIC_INLINE 00081 #endif 00082 #ifndef __NO_RETURN 00083 #define __NO_RETURN __attribute__((noreturn)) 00084 #endif 00085 #ifndef __USED 00086 #define __USED __attribute__((used)) 00087 #endif 00088 #ifndef __WEAK 00089 #define __WEAK __attribute__((weak)) 00090 #endif 00091 #ifndef __PACKED 00092 #define __PACKED __attribute__((packed)) 00093 #endif 00094 #ifndef __PACKED_STRUCT 00095 #define __PACKED_STRUCT struct __attribute__((packed)) 00096 #endif 00097 #ifndef __PACKED_UNION 00098 #define __PACKED_UNION union __attribute__((packed)) 00099 #endif 00100 #ifndef __UNALIGNED_UINT32 /* deprecated */ 00101 struct __attribute__((packed)) T_UINT32 { uint32_t v; }; 00102 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 00103 #endif 00104 #ifndef __UNALIGNED_UINT16_WRITE 00105 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 00106 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) 00107 #endif 00108 #ifndef __UNALIGNED_UINT16_READ 00109 __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 00110 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 00111 #endif 00112 #ifndef __UNALIGNED_UINT32_WRITE 00113 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 00114 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 00115 #endif 00116 #ifndef __UNALIGNED_UINT32_READ 00117 __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 00118 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 00119 #endif 00120 #ifndef __ALIGNED 00121 #define __ALIGNED(x) __attribute__((aligned(x))) 00122 #endif 00123 #ifndef __RESTRICT 00124 #define __RESTRICT __restrict 00125 #endif 00126 #ifndef __COMPILER_BARRIER 00127 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. 00128 #define __COMPILER_BARRIER() (void)0 00129 #endif 00130 00131 00132 /* 00133 * TASKING Compiler 00134 */ 00135 #elif defined ( __TASKING__ ) 00136 /* 00137 * The CMSIS functions have been implemented as intrinsics in the compiler. 00138 * Please use "carm -?i" to get an up to date list of all intrinsics, 00139 * Including the CMSIS ones. 00140 */ 00141 00142 #ifndef __ASM 00143 #define __ASM __asm 00144 #endif 00145 #ifndef __INLINE 00146 #define __INLINE inline 00147 #endif 00148 #ifndef __STATIC_INLINE 00149 #define __STATIC_INLINE static inline 00150 #endif 00151 #ifndef __STATIC_FORCEINLINE 00152 #define __STATIC_FORCEINLINE __STATIC_INLINE 00153 #endif 00154 #ifndef __NO_RETURN 00155 #define __NO_RETURN __attribute__((noreturn)) 00156 #endif 00157 #ifndef __USED 00158 #define __USED __attribute__((used)) 00159 #endif 00160 #ifndef __WEAK 00161 #define __WEAK __attribute__((weak)) 00162 #endif 00163 #ifndef __PACKED 00164 #define __PACKED __packed__ 00165 #endif 00166 #ifndef __PACKED_STRUCT 00167 #define __PACKED_STRUCT struct __packed__ 00168 #endif 00169 #ifndef __PACKED_UNION 00170 #define __PACKED_UNION union __packed__ 00171 #endif 00172 #ifndef __UNALIGNED_UINT32 /* deprecated */ 00173 struct __packed__ T_UINT32 { uint32_t v; }; 00174 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 00175 #endif 00176 #ifndef __UNALIGNED_UINT16_WRITE 00177 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 00178 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 00179 #endif 00180 #ifndef __UNALIGNED_UINT16_READ 00181 __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 00182 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 00183 #endif 00184 #ifndef __UNALIGNED_UINT32_WRITE 00185 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 00186 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 00187 #endif 00188 #ifndef __UNALIGNED_UINT32_READ 00189 __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 00190 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 00191 #endif 00192 #ifndef __ALIGNED 00193 #define __ALIGNED(x) __align(x) 00194 #endif 00195 #ifndef __RESTRICT 00196 #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 00197 #define __RESTRICT 00198 #endif 00199 #ifndef __COMPILER_BARRIER 00200 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. 00201 #define __COMPILER_BARRIER() (void)0 00202 #endif 00203 00204 00205 /* 00206 * COSMIC Compiler 00207 */ 00208 #elif defined ( __CSMC__ ) 00209 #include <cmsis_csm.h> 00210 00211 #ifndef __ASM 00212 #define __ASM _asm 00213 #endif 00214 #ifndef __INLINE 00215 #define __INLINE inline 00216 #endif 00217 #ifndef __STATIC_INLINE 00218 #define __STATIC_INLINE static inline 00219 #endif 00220 #ifndef __STATIC_FORCEINLINE 00221 #define __STATIC_FORCEINLINE __STATIC_INLINE 00222 #endif 00223 #ifndef __NO_RETURN 00224 // NO RETURN is automatically detected hence no warning here 00225 #define __NO_RETURN 00226 #endif 00227 #ifndef __USED 00228 #warning No compiler specific solution for __USED. __USED is ignored. 00229 #define __USED 00230 #endif 00231 #ifndef __WEAK 00232 #define __WEAK __weak 00233 #endif 00234 #ifndef __PACKED 00235 #define __PACKED @packed 00236 #endif 00237 #ifndef __PACKED_STRUCT 00238 #define __PACKED_STRUCT @packed struct 00239 #endif 00240 #ifndef __PACKED_UNION 00241 #define __PACKED_UNION @packed union 00242 #endif 00243 #ifndef __UNALIGNED_UINT32 /* deprecated */ 00244 @packed struct T_UINT32 { uint32_t v; }; 00245 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 00246 #endif 00247 #ifndef __UNALIGNED_UINT16_WRITE 00248 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 00249 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 00250 #endif 00251 #ifndef __UNALIGNED_UINT16_READ 00252 __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 00253 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 00254 #endif 00255 #ifndef __UNALIGNED_UINT32_WRITE 00256 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 00257 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 00258 #endif 00259 #ifndef __UNALIGNED_UINT32_READ 00260 __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 00261 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 00262 #endif 00263 #ifndef __ALIGNED 00264 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. 00265 #define __ALIGNED(x) 00266 #endif 00267 #ifndef __RESTRICT 00268 #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 00269 #define __RESTRICT 00270 #endif 00271 #ifndef __COMPILER_BARRIER 00272 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. 00273 #define __COMPILER_BARRIER() (void)0 00274 #endif 00275 00276 00277 #else 00278 #error Unknown compiler. 00279 #endif 00280 00281 00282 #endif /* __CMSIS_COMPILER_H */ 00283
Generated on Tue Jul 12 2022 15:37:13 by
