cmsis_compiler.h 6.9 KB

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