1 /**************************************************************************//** 2 * @file cmsis_compiler.h 3 * @brief CMSIS compiler specific macros, functions, instructions 4 * @version V1.0.2 5 * @date 10. January 2018 6 ******************************************************************************/ 7 /* 8 * Copyright (c) 2009-2018 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_CA_H 26 #define __CMSIS_COMPILER_CA_H 27 28 #include <stdint.h> 29 30 /* 31 * Arm Compiler 4/5 32 */ 33 #if defined ( __CC_ARM ) 34 #include "ca/cmsis_armcc_ca.h" 35 36 37 /* 38 * Arm Compiler 6 (armclang) 39 */ 40 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 41 #include "ca/cmsis_armclang_ca.h" 42 43 44 /* 45 * GNU Compiler 46 */ 47 #elif defined ( __GNUC__ ) 48 #include "ca/cmsis_gcc_ca.h" 49 50 51 /* 52 * IAR Compiler 53 */ 54 #elif defined ( __ICCARM__ ) 55 #include "ca/cmsis_iccarm_ca.h" 56 57 58 /* 59 * TI Arm Compiler 60 */ 61 #elif defined ( __TI_ARM__ ) 62 #include <ca/cmsis_ccs_ca.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 __STATIC_INLINE 74 #define __STATIC_INLINE static inline 75 #endif 76 #ifndef __STATIC_FORCEINLINE 77 #define __STATIC_FORCEINLINE __STATIC_INLINE 78 #endif 79 #ifndef __NO_RETURN 80 #define __NO_RETURN __attribute__((noreturn)) 81 #endif 82 #ifndef CMSIS_DEPRECATED 83 #define CMSIS_DEPRECATED __attribute__((deprecated)) 84 #endif 85 #ifndef __USED 86 #define __USED __attribute__((used)) 87 #endif 88 #ifndef __WEAK 89 #define __WEAK __attribute__((weak)) 90 #endif 91 #ifndef __UNALIGNED_UINT32 92 struct __attribute__((packed)) T_UINT32 { uint32_t v; }; 93 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 94 #endif 95 #ifndef __ALIGNED 96 #define __ALIGNED(x) __attribute__((aligned(x))) 97 #endif 98 #ifndef __PACKED 99 #define __PACKED __attribute__((packed)) 100 #endif 101 #ifndef __COMPILER_BARRIER 102 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. 103 #define __COMPILER_BARRIER() (void)0 104 #endif 105 106 107 /* 108 * TASKING Compiler 109 */ 110 #elif defined ( __TASKING__ ) 111 /* 112 * The CMSIS functions have been implemented as intrinsics in the compiler. 113 * Please use "carm -?i" to get an up to date list of all intrinsics, 114 * Including the CMSIS ones. 115 */ 116 117 #ifndef __ASM 118 #define __ASM __asm 119 #endif 120 #ifndef __INLINE 121 #define __INLINE inline 122 #endif 123 #ifndef __STATIC_INLINE 124 #define __STATIC_INLINE static inline 125 #endif 126 #ifndef __STATIC_FORCEINLINE 127 #define __STATIC_FORCEINLINE __STATIC_INLINE 128 #endif 129 #ifndef __NO_RETURN 130 #define __NO_RETURN __attribute__((noreturn)) 131 #endif 132 #ifndef CMSIS_DEPRECATED 133 #define CMSIS_DEPRECATED __attribute__((deprecated)) 134 #endif 135 #ifndef __USED 136 #define __USED __attribute__((used)) 137 #endif 138 #ifndef __WEAK 139 #define __WEAK __attribute__((weak)) 140 #endif 141 #ifndef __UNALIGNED_UINT32 142 struct __packed__ T_UINT32 { uint32_t v; }; 143 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 144 #endif 145 #ifndef __ALIGNED 146 #define __ALIGNED(x) __align(x) 147 #endif 148 #ifndef __PACKED 149 #define __PACKED __packed__ 150 #endif 151 #ifndef __COMPILER_BARRIER 152 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. 153 #define __COMPILER_BARRIER() (void)0 154 #endif 155 156 157 /* 158 * COSMIC Compiler 159 */ 160 #elif defined ( __CSMC__ ) 161 #include <ca/cmsis_csm_ca.h> 162 163 #ifndef __ASM 164 #define __ASM _asm 165 #endif 166 #ifndef __INLINE 167 #define __INLINE inline 168 #endif 169 #ifndef __STATIC_INLINE 170 #define __STATIC_INLINE static inline 171 #endif 172 #ifndef __STATIC_FORCEINLINE 173 #define __STATIC_FORCEINLINE __STATIC_INLINE 174 #endif 175 #ifndef __NO_RETURN 176 // NO RETURN is automatically detected hence no warning here 177 #define __NO_RETURN 178 #endif 179 #ifndef __USED 180 #warning No compiler specific solution for __USED. __USED is ignored. 181 #define __USED 182 #endif 183 #ifndef CMSIS_DEPRECATED 184 #warning No compiler specific solution for CMSIS_DEPRECATED. CMSIS_DEPRECATED is ignored. 185 #define CMSIS_DEPRECATED 186 #endif 187 #ifndef __WEAK 188 #define __WEAK __weak 189 #endif 190 #ifndef __UNALIGNED_UINT32 191 @packed struct T_UINT32 { uint32_t v; }; 192 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 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 #define __PACKED @packed 200 #endif 201 #ifndef __COMPILER_BARRIER 202 #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. 203 #define __COMPILER_BARRIER() (void)0 204 #endif 205 206 207 #else 208 #error Unknown compiler. 209 #endif 210 211 212 #endif /* __CMSIS_COMPILER_CA_H */ 213 214