1*225f4ba4SMatthias Ringwald /**************************************************************************//** 2*225f4ba4SMatthias Ringwald * @file cmsis_compiler.h 3*225f4ba4SMatthias Ringwald * @brief CMSIS compiler generic header file 4*225f4ba4SMatthias Ringwald * @version V5.0.4 5*225f4ba4SMatthias Ringwald * @date 10. January 2018 6*225f4ba4SMatthias Ringwald ******************************************************************************/ 7*225f4ba4SMatthias Ringwald /* 8*225f4ba4SMatthias Ringwald * Copyright (c) 2009-2018 Arm Limited. All rights reserved. 9*225f4ba4SMatthias Ringwald * 10*225f4ba4SMatthias Ringwald * SPDX-License-Identifier: Apache-2.0 11*225f4ba4SMatthias Ringwald * 12*225f4ba4SMatthias Ringwald * Licensed under the Apache License, Version 2.0 (the License); you may 13*225f4ba4SMatthias Ringwald * not use this file except in compliance with the License. 14*225f4ba4SMatthias Ringwald * You may obtain a copy of the License at 15*225f4ba4SMatthias Ringwald * 16*225f4ba4SMatthias Ringwald * www.apache.org/licenses/LICENSE-2.0 17*225f4ba4SMatthias Ringwald * 18*225f4ba4SMatthias Ringwald * Unless required by applicable law or agreed to in writing, software 19*225f4ba4SMatthias Ringwald * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20*225f4ba4SMatthias Ringwald * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21*225f4ba4SMatthias Ringwald * See the License for the specific language governing permissions and 22*225f4ba4SMatthias Ringwald * limitations under the License. 23*225f4ba4SMatthias Ringwald */ 24*225f4ba4SMatthias Ringwald 25*225f4ba4SMatthias Ringwald #ifndef __CMSIS_COMPILER_H 26*225f4ba4SMatthias Ringwald #define __CMSIS_COMPILER_H 27*225f4ba4SMatthias Ringwald 28*225f4ba4SMatthias Ringwald #include <stdint.h> 29*225f4ba4SMatthias Ringwald 30*225f4ba4SMatthias Ringwald /* 31*225f4ba4SMatthias Ringwald * Arm Compiler 4/5 32*225f4ba4SMatthias Ringwald */ 33*225f4ba4SMatthias Ringwald #if defined ( __CC_ARM ) 34*225f4ba4SMatthias Ringwald #include "cmsis_armcc.h" 35*225f4ba4SMatthias Ringwald 36*225f4ba4SMatthias Ringwald 37*225f4ba4SMatthias Ringwald /* 38*225f4ba4SMatthias Ringwald * Arm Compiler 6 (armclang) 39*225f4ba4SMatthias Ringwald */ 40*225f4ba4SMatthias Ringwald #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 41*225f4ba4SMatthias Ringwald #include "cmsis_armclang.h" 42*225f4ba4SMatthias Ringwald 43*225f4ba4SMatthias Ringwald 44*225f4ba4SMatthias Ringwald /* 45*225f4ba4SMatthias Ringwald * GNU Compiler 46*225f4ba4SMatthias Ringwald */ 47*225f4ba4SMatthias Ringwald #elif defined ( __GNUC__ ) 48*225f4ba4SMatthias Ringwald #include "cmsis_gcc.h" 49*225f4ba4SMatthias Ringwald 50*225f4ba4SMatthias Ringwald 51*225f4ba4SMatthias Ringwald /* 52*225f4ba4SMatthias Ringwald * IAR Compiler 53*225f4ba4SMatthias Ringwald */ 54*225f4ba4SMatthias Ringwald #elif defined ( __ICCARM__ ) 55*225f4ba4SMatthias Ringwald #include <cmsis_iccarm.h> 56*225f4ba4SMatthias Ringwald 57*225f4ba4SMatthias Ringwald 58*225f4ba4SMatthias Ringwald /* 59*225f4ba4SMatthias Ringwald * TI Arm Compiler 60*225f4ba4SMatthias Ringwald */ 61*225f4ba4SMatthias Ringwald #elif defined ( __TI_ARM__ ) 62*225f4ba4SMatthias Ringwald #include <cmsis_ccs.h> 63*225f4ba4SMatthias Ringwald 64*225f4ba4SMatthias Ringwald #ifndef __ASM 65*225f4ba4SMatthias Ringwald #define __ASM __asm 66*225f4ba4SMatthias Ringwald #endif 67*225f4ba4SMatthias Ringwald #ifndef __INLINE 68*225f4ba4SMatthias Ringwald #define __INLINE inline 69*225f4ba4SMatthias Ringwald #endif 70*225f4ba4SMatthias Ringwald #ifndef __STATIC_INLINE 71*225f4ba4SMatthias Ringwald #define __STATIC_INLINE static inline 72*225f4ba4SMatthias Ringwald #endif 73*225f4ba4SMatthias Ringwald #ifndef __STATIC_FORCEINLINE 74*225f4ba4SMatthias Ringwald #define __STATIC_FORCEINLINE __STATIC_INLINE 75*225f4ba4SMatthias Ringwald #endif 76*225f4ba4SMatthias Ringwald #ifndef __NO_RETURN 77*225f4ba4SMatthias Ringwald #define __NO_RETURN __attribute__((noreturn)) 78*225f4ba4SMatthias Ringwald #endif 79*225f4ba4SMatthias Ringwald #ifndef __USED 80*225f4ba4SMatthias Ringwald #define __USED __attribute__((used)) 81*225f4ba4SMatthias Ringwald #endif 82*225f4ba4SMatthias Ringwald #ifndef __WEAK 83*225f4ba4SMatthias Ringwald #define __WEAK __attribute__((weak)) 84*225f4ba4SMatthias Ringwald #endif 85*225f4ba4SMatthias Ringwald #ifndef __PACKED 86*225f4ba4SMatthias Ringwald #define __PACKED __attribute__((packed)) 87*225f4ba4SMatthias Ringwald #endif 88*225f4ba4SMatthias Ringwald #ifndef __PACKED_STRUCT 89*225f4ba4SMatthias Ringwald #define __PACKED_STRUCT struct __attribute__((packed)) 90*225f4ba4SMatthias Ringwald #endif 91*225f4ba4SMatthias Ringwald #ifndef __PACKED_UNION 92*225f4ba4SMatthias Ringwald #define __PACKED_UNION union __attribute__((packed)) 93*225f4ba4SMatthias Ringwald #endif 94*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT32 /* deprecated */ 95*225f4ba4SMatthias Ringwald struct __attribute__((packed)) T_UINT32 { uint32_t v; }; 96*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 97*225f4ba4SMatthias Ringwald #endif 98*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT16_WRITE 99*225f4ba4SMatthias Ringwald __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 100*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) 101*225f4ba4SMatthias Ringwald #endif 102*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT16_READ 103*225f4ba4SMatthias Ringwald __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 104*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 105*225f4ba4SMatthias Ringwald #endif 106*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT32_WRITE 107*225f4ba4SMatthias Ringwald __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 108*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 109*225f4ba4SMatthias Ringwald #endif 110*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT32_READ 111*225f4ba4SMatthias Ringwald __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 112*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 113*225f4ba4SMatthias Ringwald #endif 114*225f4ba4SMatthias Ringwald #ifndef __ALIGNED 115*225f4ba4SMatthias Ringwald #define __ALIGNED(x) __attribute__((aligned(x))) 116*225f4ba4SMatthias Ringwald #endif 117*225f4ba4SMatthias Ringwald #ifndef __RESTRICT 118*225f4ba4SMatthias Ringwald #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 119*225f4ba4SMatthias Ringwald #define __RESTRICT 120*225f4ba4SMatthias Ringwald #endif 121*225f4ba4SMatthias Ringwald 122*225f4ba4SMatthias Ringwald 123*225f4ba4SMatthias Ringwald /* 124*225f4ba4SMatthias Ringwald * TASKING Compiler 125*225f4ba4SMatthias Ringwald */ 126*225f4ba4SMatthias Ringwald #elif defined ( __TASKING__ ) 127*225f4ba4SMatthias Ringwald /* 128*225f4ba4SMatthias Ringwald * The CMSIS functions have been implemented as intrinsics in the compiler. 129*225f4ba4SMatthias Ringwald * Please use "carm -?i" to get an up to date list of all intrinsics, 130*225f4ba4SMatthias Ringwald * Including the CMSIS ones. 131*225f4ba4SMatthias Ringwald */ 132*225f4ba4SMatthias Ringwald 133*225f4ba4SMatthias Ringwald #ifndef __ASM 134*225f4ba4SMatthias Ringwald #define __ASM __asm 135*225f4ba4SMatthias Ringwald #endif 136*225f4ba4SMatthias Ringwald #ifndef __INLINE 137*225f4ba4SMatthias Ringwald #define __INLINE inline 138*225f4ba4SMatthias Ringwald #endif 139*225f4ba4SMatthias Ringwald #ifndef __STATIC_INLINE 140*225f4ba4SMatthias Ringwald #define __STATIC_INLINE static inline 141*225f4ba4SMatthias Ringwald #endif 142*225f4ba4SMatthias Ringwald #ifndef __STATIC_FORCEINLINE 143*225f4ba4SMatthias Ringwald #define __STATIC_FORCEINLINE __STATIC_INLINE 144*225f4ba4SMatthias Ringwald #endif 145*225f4ba4SMatthias Ringwald #ifndef __NO_RETURN 146*225f4ba4SMatthias Ringwald #define __NO_RETURN __attribute__((noreturn)) 147*225f4ba4SMatthias Ringwald #endif 148*225f4ba4SMatthias Ringwald #ifndef __USED 149*225f4ba4SMatthias Ringwald #define __USED __attribute__((used)) 150*225f4ba4SMatthias Ringwald #endif 151*225f4ba4SMatthias Ringwald #ifndef __WEAK 152*225f4ba4SMatthias Ringwald #define __WEAK __attribute__((weak)) 153*225f4ba4SMatthias Ringwald #endif 154*225f4ba4SMatthias Ringwald #ifndef __PACKED 155*225f4ba4SMatthias Ringwald #define __PACKED __packed__ 156*225f4ba4SMatthias Ringwald #endif 157*225f4ba4SMatthias Ringwald #ifndef __PACKED_STRUCT 158*225f4ba4SMatthias Ringwald #define __PACKED_STRUCT struct __packed__ 159*225f4ba4SMatthias Ringwald #endif 160*225f4ba4SMatthias Ringwald #ifndef __PACKED_UNION 161*225f4ba4SMatthias Ringwald #define __PACKED_UNION union __packed__ 162*225f4ba4SMatthias Ringwald #endif 163*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT32 /* deprecated */ 164*225f4ba4SMatthias Ringwald struct __packed__ T_UINT32 { uint32_t v; }; 165*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 166*225f4ba4SMatthias Ringwald #endif 167*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT16_WRITE 168*225f4ba4SMatthias Ringwald __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 169*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 170*225f4ba4SMatthias Ringwald #endif 171*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT16_READ 172*225f4ba4SMatthias Ringwald __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 173*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 174*225f4ba4SMatthias Ringwald #endif 175*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT32_WRITE 176*225f4ba4SMatthias Ringwald __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 177*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 178*225f4ba4SMatthias Ringwald #endif 179*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT32_READ 180*225f4ba4SMatthias Ringwald __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 181*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 182*225f4ba4SMatthias Ringwald #endif 183*225f4ba4SMatthias Ringwald #ifndef __ALIGNED 184*225f4ba4SMatthias Ringwald #define __ALIGNED(x) __align(x) 185*225f4ba4SMatthias Ringwald #endif 186*225f4ba4SMatthias Ringwald #ifndef __RESTRICT 187*225f4ba4SMatthias Ringwald #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 188*225f4ba4SMatthias Ringwald #define __RESTRICT 189*225f4ba4SMatthias Ringwald #endif 190*225f4ba4SMatthias Ringwald 191*225f4ba4SMatthias Ringwald 192*225f4ba4SMatthias Ringwald /* 193*225f4ba4SMatthias Ringwald * COSMIC Compiler 194*225f4ba4SMatthias Ringwald */ 195*225f4ba4SMatthias Ringwald #elif defined ( __CSMC__ ) 196*225f4ba4SMatthias Ringwald #include <cmsis_csm.h> 197*225f4ba4SMatthias Ringwald 198*225f4ba4SMatthias Ringwald #ifndef __ASM 199*225f4ba4SMatthias Ringwald #define __ASM _asm 200*225f4ba4SMatthias Ringwald #endif 201*225f4ba4SMatthias Ringwald #ifndef __INLINE 202*225f4ba4SMatthias Ringwald #define __INLINE inline 203*225f4ba4SMatthias Ringwald #endif 204*225f4ba4SMatthias Ringwald #ifndef __STATIC_INLINE 205*225f4ba4SMatthias Ringwald #define __STATIC_INLINE static inline 206*225f4ba4SMatthias Ringwald #endif 207*225f4ba4SMatthias Ringwald #ifndef __STATIC_FORCEINLINE 208*225f4ba4SMatthias Ringwald #define __STATIC_FORCEINLINE __STATIC_INLINE 209*225f4ba4SMatthias Ringwald #endif 210*225f4ba4SMatthias Ringwald #ifndef __NO_RETURN 211*225f4ba4SMatthias Ringwald // NO RETURN is automatically detected hence no warning here 212*225f4ba4SMatthias Ringwald #define __NO_RETURN 213*225f4ba4SMatthias Ringwald #endif 214*225f4ba4SMatthias Ringwald #ifndef __USED 215*225f4ba4SMatthias Ringwald #warning No compiler specific solution for __USED. __USED is ignored. 216*225f4ba4SMatthias Ringwald #define __USED 217*225f4ba4SMatthias Ringwald #endif 218*225f4ba4SMatthias Ringwald #ifndef __WEAK 219*225f4ba4SMatthias Ringwald #define __WEAK __weak 220*225f4ba4SMatthias Ringwald #endif 221*225f4ba4SMatthias Ringwald #ifndef __PACKED 222*225f4ba4SMatthias Ringwald #define __PACKED @packed 223*225f4ba4SMatthias Ringwald #endif 224*225f4ba4SMatthias Ringwald #ifndef __PACKED_STRUCT 225*225f4ba4SMatthias Ringwald #define __PACKED_STRUCT @packed struct 226*225f4ba4SMatthias Ringwald #endif 227*225f4ba4SMatthias Ringwald #ifndef __PACKED_UNION 228*225f4ba4SMatthias Ringwald #define __PACKED_UNION @packed union 229*225f4ba4SMatthias Ringwald #endif 230*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT32 /* deprecated */ 231*225f4ba4SMatthias Ringwald @packed struct T_UINT32 { uint32_t v; }; 232*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 233*225f4ba4SMatthias Ringwald #endif 234*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT16_WRITE 235*225f4ba4SMatthias Ringwald __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 236*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 237*225f4ba4SMatthias Ringwald #endif 238*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT16_READ 239*225f4ba4SMatthias Ringwald __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 240*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 241*225f4ba4SMatthias Ringwald #endif 242*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT32_WRITE 243*225f4ba4SMatthias Ringwald __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 244*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 245*225f4ba4SMatthias Ringwald #endif 246*225f4ba4SMatthias Ringwald #ifndef __UNALIGNED_UINT32_READ 247*225f4ba4SMatthias Ringwald __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 248*225f4ba4SMatthias Ringwald #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 249*225f4ba4SMatthias Ringwald #endif 250*225f4ba4SMatthias Ringwald #ifndef __ALIGNED 251*225f4ba4SMatthias Ringwald #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. 252*225f4ba4SMatthias Ringwald #define __ALIGNED(x) 253*225f4ba4SMatthias Ringwald #endif 254*225f4ba4SMatthias Ringwald #ifndef __RESTRICT 255*225f4ba4SMatthias Ringwald #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 256*225f4ba4SMatthias Ringwald #define __RESTRICT 257*225f4ba4SMatthias Ringwald #endif 258*225f4ba4SMatthias Ringwald 259*225f4ba4SMatthias Ringwald 260*225f4ba4SMatthias Ringwald #else 261*225f4ba4SMatthias Ringwald #error Unknown compiler. 262*225f4ba4SMatthias Ringwald #endif 263*225f4ba4SMatthias Ringwald 264*225f4ba4SMatthias Ringwald 265*225f4ba4SMatthias Ringwald #endif /* __CMSIS_COMPILER_H */ 266*225f4ba4SMatthias Ringwald 267