cmsis_compiler.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. #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 (armclang)
  34. */
  35. #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  36. #include "cmsis_armclang.h"
  37. /*
  38. * GNU Compiler
  39. */
  40. #elif defined ( __GNUC__ )
  41. #include "cmsis_gcc.h"
  42. /*
  43. * IAR Compiler
  44. */
  45. #elif defined ( __ICCARM__ )
  46. #include "cmsis_iccarm.h"
  47. /*
  48. * TI Arm Compiler
  49. */
  50. #elif defined ( __TI_ARM__ )
  51. #include <cmsis_ccs.h>
  52. #ifndef __ASM
  53. #define __ASM __asm
  54. #endif
  55. #ifndef __INLINE
  56. #define __INLINE inline
  57. #endif
  58. #ifndef __STATIC_INLINE
  59. #define __STATIC_INLINE static inline
  60. #endif
  61. #ifndef __STATIC_INLINE
  62. #define __STATIC_INLINE static inline
  63. #endif
  64. #ifndef __STATIC_FORCEINLINE
  65. #define __STATIC_FORCEINLINE __STATIC_INLINE
  66. #endif
  67. #ifndef __NO_RETURN
  68. #define __NO_RETURN __attribute__((noreturn))
  69. #endif
  70. #ifndef CMSIS_DEPRECATED
  71. #define CMSIS_DEPRECATED __attribute__((deprecated))
  72. #endif
  73. #ifndef __USED
  74. #define __USED __attribute__((used))
  75. #endif
  76. #ifndef __WEAK
  77. #define __WEAK __attribute__((weak))
  78. #endif
  79. #ifndef __UNALIGNED_UINT32
  80. struct __attribute__((packed)) T_UINT32 { uint32_t v; };
  81. #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
  82. #endif
  83. #ifndef __ALIGNED
  84. #define __ALIGNED(x) __attribute__((aligned(x)))
  85. #endif
  86. #ifndef __PACKED
  87. #define __PACKED __attribute__((packed))
  88. #endif
  89. #ifndef __COMPILER_BARRIER
  90. #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
  91. #define __COMPILER_BARRIER() (void)0
  92. #endif
  93. /*
  94. * TASKING Compiler
  95. */
  96. #elif defined ( __TASKING__ )
  97. /*
  98. * The CMSIS functions have been implemented as intrinsics in the compiler.
  99. * Please use "carm -?i" to get an up to date list of all intrinsics,
  100. * Including the CMSIS ones.
  101. */
  102. #ifndef __ASM
  103. #define __ASM __asm
  104. #endif
  105. #ifndef __INLINE
  106. #define __INLINE inline
  107. #endif
  108. #ifndef __STATIC_INLINE
  109. #define __STATIC_INLINE static inline
  110. #endif
  111. #ifndef __STATIC_FORCEINLINE
  112. #define __STATIC_FORCEINLINE __STATIC_INLINE
  113. #endif
  114. #ifndef __NO_RETURN
  115. #define __NO_RETURN __attribute__((noreturn))
  116. #endif
  117. #ifndef CMSIS_DEPRECATED
  118. #define CMSIS_DEPRECATED __attribute__((deprecated))
  119. #endif
  120. #ifndef __USED
  121. #define __USED __attribute__((used))
  122. #endif
  123. #ifndef __WEAK
  124. #define __WEAK __attribute__((weak))
  125. #endif
  126. #ifndef __UNALIGNED_UINT32
  127. struct __packed__ T_UINT32 { uint32_t v; };
  128. #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
  129. #endif
  130. #ifndef __ALIGNED
  131. #define __ALIGNED(x) __align(x)
  132. #endif
  133. #ifndef __PACKED
  134. #define __PACKED __packed__
  135. #endif
  136. #ifndef __COMPILER_BARRIER
  137. #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
  138. #define __COMPILER_BARRIER() (void)0
  139. #endif
  140. /*
  141. * COSMIC Compiler
  142. */
  143. #elif defined ( __CSMC__ )
  144. #include <cmsis_csm.h>
  145. #ifndef __ASM
  146. #define __ASM _asm
  147. #endif
  148. #ifndef __INLINE
  149. #define __INLINE inline
  150. #endif
  151. #ifndef __STATIC_INLINE
  152. #define __STATIC_INLINE static inline
  153. #endif
  154. #ifndef __STATIC_FORCEINLINE
  155. #define __STATIC_FORCEINLINE __STATIC_INLINE
  156. #endif
  157. #ifndef __NO_RETURN
  158. // NO RETURN is automatically detected hence no warning here
  159. #define __NO_RETURN
  160. #endif
  161. #ifndef __USED
  162. #warning No compiler specific solution for __USED. __USED is ignored.
  163. #define __USED
  164. #endif
  165. #ifndef CMSIS_DEPRECATED
  166. #warning No compiler specific solution for CMSIS_DEPRECATED. CMSIS_DEPRECATED is ignored.
  167. #define CMSIS_DEPRECATED
  168. #endif
  169. #ifndef __WEAK
  170. #define __WEAK __weak
  171. #endif
  172. #ifndef __UNALIGNED_UINT32
  173. @packed struct T_UINT32 { uint32_t v; };
  174. #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
  175. #endif
  176. #ifndef __ALIGNED
  177. #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
  178. #define __ALIGNED(x)
  179. #endif
  180. #ifndef __PACKED
  181. #define __PACKED @packed
  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. #else
  188. #error Unknown compiler.
  189. #endif
  190. #endif /* __CMSIS_COMPILER_H */