PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

cmsis_compiler.h 9.3KB

pirms 3 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /**************************************************************************//**
  2. * @file cmsis_compiler.h
  3. * @brief CMSIS compiler generic header file
  4. * @version V5.1.0
  5. * @date 09. October 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. #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 __USED
  73. #define __USED __attribute__((used))
  74. #endif
  75. #ifndef __WEAK
  76. #define __WEAK __attribute__((weak))
  77. #endif
  78. #ifndef __PACKED
  79. #define __PACKED __attribute__((packed))
  80. #endif
  81. #ifndef __PACKED_STRUCT
  82. #define __PACKED_STRUCT struct __attribute__((packed))
  83. #endif
  84. #ifndef __PACKED_UNION
  85. #define __PACKED_UNION union __attribute__((packed))
  86. #endif
  87. #ifndef __UNALIGNED_UINT32 /* deprecated */
  88. struct __attribute__((packed)) T_UINT32 { uint32_t v; };
  89. #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
  90. #endif
  91. #ifndef __UNALIGNED_UINT16_WRITE
  92. __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
  93. #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
  94. #endif
  95. #ifndef __UNALIGNED_UINT16_READ
  96. __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
  97. #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
  98. #endif
  99. #ifndef __UNALIGNED_UINT32_WRITE
  100. __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
  101. #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
  102. #endif
  103. #ifndef __UNALIGNED_UINT32_READ
  104. __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
  105. #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
  106. #endif
  107. #ifndef __ALIGNED
  108. #define __ALIGNED(x) __attribute__((aligned(x)))
  109. #endif
  110. #ifndef __RESTRICT
  111. #define __RESTRICT __restrict
  112. #endif
  113. #ifndef __COMPILER_BARRIER
  114. #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
  115. #define __COMPILER_BARRIER() (void)0
  116. #endif
  117. /*
  118. * TASKING Compiler
  119. */
  120. #elif defined ( __TASKING__ )
  121. /*
  122. * The CMSIS functions have been implemented as intrinsics in the compiler.
  123. * Please use "carm -?i" to get an up to date list of all intrinsics,
  124. * Including the CMSIS ones.
  125. */
  126. #ifndef __ASM
  127. #define __ASM __asm
  128. #endif
  129. #ifndef __INLINE
  130. #define __INLINE inline
  131. #endif
  132. #ifndef __STATIC_INLINE
  133. #define __STATIC_INLINE static inline
  134. #endif
  135. #ifndef __STATIC_FORCEINLINE
  136. #define __STATIC_FORCEINLINE __STATIC_INLINE
  137. #endif
  138. #ifndef __NO_RETURN
  139. #define __NO_RETURN __attribute__((noreturn))
  140. #endif
  141. #ifndef __USED
  142. #define __USED __attribute__((used))
  143. #endif
  144. #ifndef __WEAK
  145. #define __WEAK __attribute__((weak))
  146. #endif
  147. #ifndef __PACKED
  148. #define __PACKED __packed__
  149. #endif
  150. #ifndef __PACKED_STRUCT
  151. #define __PACKED_STRUCT struct __packed__
  152. #endif
  153. #ifndef __PACKED_UNION
  154. #define __PACKED_UNION union __packed__
  155. #endif
  156. #ifndef __UNALIGNED_UINT32 /* deprecated */
  157. struct __packed__ T_UINT32 { uint32_t v; };
  158. #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
  159. #endif
  160. #ifndef __UNALIGNED_UINT16_WRITE
  161. __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
  162. #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
  163. #endif
  164. #ifndef __UNALIGNED_UINT16_READ
  165. __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
  166. #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
  167. #endif
  168. #ifndef __UNALIGNED_UINT32_WRITE
  169. __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
  170. #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
  171. #endif
  172. #ifndef __UNALIGNED_UINT32_READ
  173. __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
  174. #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
  175. #endif
  176. #ifndef __ALIGNED
  177. #define __ALIGNED(x) __align(x)
  178. #endif
  179. #ifndef __RESTRICT
  180. #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
  181. #define __RESTRICT
  182. #endif
  183. #ifndef __COMPILER_BARRIER
  184. #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
  185. #define __COMPILER_BARRIER() (void)0
  186. #endif
  187. /*
  188. * COSMIC Compiler
  189. */
  190. #elif defined ( __CSMC__ )
  191. #include <cmsis_csm.h>
  192. #ifndef __ASM
  193. #define __ASM _asm
  194. #endif
  195. #ifndef __INLINE
  196. #define __INLINE inline
  197. #endif
  198. #ifndef __STATIC_INLINE
  199. #define __STATIC_INLINE static inline
  200. #endif
  201. #ifndef __STATIC_FORCEINLINE
  202. #define __STATIC_FORCEINLINE __STATIC_INLINE
  203. #endif
  204. #ifndef __NO_RETURN
  205. // NO RETURN is automatically detected hence no warning here
  206. #define __NO_RETURN
  207. #endif
  208. #ifndef __USED
  209. #warning No compiler specific solution for __USED. __USED is ignored.
  210. #define __USED
  211. #endif
  212. #ifndef __WEAK
  213. #define __WEAK __weak
  214. #endif
  215. #ifndef __PACKED
  216. #define __PACKED @packed
  217. #endif
  218. #ifndef __PACKED_STRUCT
  219. #define __PACKED_STRUCT @packed struct
  220. #endif
  221. #ifndef __PACKED_UNION
  222. #define __PACKED_UNION @packed union
  223. #endif
  224. #ifndef __UNALIGNED_UINT32 /* deprecated */
  225. @packed struct T_UINT32 { uint32_t v; };
  226. #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
  227. #endif
  228. #ifndef __UNALIGNED_UINT16_WRITE
  229. __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
  230. #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
  231. #endif
  232. #ifndef __UNALIGNED_UINT16_READ
  233. __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
  234. #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
  235. #endif
  236. #ifndef __UNALIGNED_UINT32_WRITE
  237. __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
  238. #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
  239. #endif
  240. #ifndef __UNALIGNED_UINT32_READ
  241. __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
  242. #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
  243. #endif
  244. #ifndef __ALIGNED
  245. #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
  246. #define __ALIGNED(x)
  247. #endif
  248. #ifndef __RESTRICT
  249. #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
  250. #define __RESTRICT
  251. #endif
  252. #ifndef __COMPILER_BARRIER
  253. #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
  254. #define __COMPILER_BARRIER() (void)0
  255. #endif
  256. #else
  257. #error Unknown compiler.
  258. #endif
  259. #endif /* __CMSIS_COMPILER_H */