cmsis_compiler.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. /*
  90. * TASKING Compiler
  91. */
  92. #elif defined ( __TASKING__ )
  93. /*
  94. * The CMSIS functions have been implemented as intrinsics in the compiler.
  95. * Please use "carm -?i" to get an up to date list of all intrinsics,
  96. * Including the CMSIS ones.
  97. */
  98. #ifndef __ASM
  99. #define __ASM __asm
  100. #endif
  101. #ifndef __INLINE
  102. #define __INLINE inline
  103. #endif
  104. #ifndef __STATIC_INLINE
  105. #define __STATIC_INLINE static inline
  106. #endif
  107. #ifndef __STATIC_FORCEINLINE
  108. #define __STATIC_FORCEINLINE __STATIC_INLINE
  109. #endif
  110. #ifndef __NO_RETURN
  111. #define __NO_RETURN __attribute__((noreturn))
  112. #endif
  113. #ifndef CMSIS_DEPRECATED
  114. #define CMSIS_DEPRECATED __attribute__((deprecated))
  115. #endif
  116. #ifndef __USED
  117. #define __USED __attribute__((used))
  118. #endif
  119. #ifndef __WEAK
  120. #define __WEAK __attribute__((weak))
  121. #endif
  122. #ifndef __UNALIGNED_UINT32
  123. struct __packed__ T_UINT32 { uint32_t v; };
  124. #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
  125. #endif
  126. #ifndef __ALIGNED
  127. #define __ALIGNED(x) __align(x)
  128. #endif
  129. #ifndef __PACKED
  130. #define __PACKED __packed__
  131. #endif
  132. /*
  133. * COSMIC Compiler
  134. */
  135. #elif defined ( __CSMC__ )
  136. #include <cmsis_csm.h>
  137. #ifndef __ASM
  138. #define __ASM _asm
  139. #endif
  140. #ifndef __INLINE
  141. #define __INLINE inline
  142. #endif
  143. #ifndef __STATIC_INLINE
  144. #define __STATIC_INLINE static inline
  145. #endif
  146. #ifndef __STATIC_FORCEINLINE
  147. #define __STATIC_FORCEINLINE __STATIC_INLINE
  148. #endif
  149. #ifndef __NO_RETURN
  150. // NO RETURN is automatically detected hence no warning here
  151. #define __NO_RETURN
  152. #endif
  153. #ifndef __USED
  154. #warning No compiler specific solution for __USED. __USED is ignored.
  155. #define __USED
  156. #endif
  157. #ifndef CMSIS_DEPRECATED
  158. #warning No compiler specific solution for CMSIS_DEPRECATED. CMSIS_DEPRECATED is ignored.
  159. #define CMSIS_DEPRECATED
  160. #endif
  161. #ifndef __WEAK
  162. #define __WEAK __weak
  163. #endif
  164. #ifndef __UNALIGNED_UINT32
  165. @packed struct T_UINT32 { uint32_t v; };
  166. #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
  167. #endif
  168. #ifndef __ALIGNED
  169. #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
  170. #define __ALIGNED(x)
  171. #endif
  172. #ifndef __PACKED
  173. #define __PACKED @packed
  174. #endif
  175. #else
  176. #error Unknown compiler.
  177. #endif
  178. #endif /* __CMSIS_COMPILER_H */