ccportab.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * @file GCC/ccportab.h
  15. * @brief Compiler portability layer.
  16. *
  17. * @defgroup CC_PORTAB Compiler portability.
  18. * @{
  19. */
  20. #ifndef CCPORTAB_H
  21. #define CCPORTAB_H
  22. /*===========================================================================*/
  23. /* Module constants. */
  24. /*===========================================================================*/
  25. /*===========================================================================*/
  26. /* Module pre-compile time settings. */
  27. /*===========================================================================*/
  28. /*===========================================================================*/
  29. /* Derived constants and error checks. */
  30. /*===========================================================================*/
  31. /*===========================================================================*/
  32. /* Module data structures and types. */
  33. /*===========================================================================*/
  34. /*===========================================================================*/
  35. /* Module macros. */
  36. /*===========================================================================*/
  37. /**
  38. * @name Compiler abstraction macros
  39. * @{
  40. */
  41. /**
  42. * @brief Allocates a variable or function to a specific section.
  43. * @note If the compiler does not support such a feature then this macro
  44. * must not be defined or it could originate errors.
  45. */
  46. #define CC_SECTION(s) __attribute__((section(s)))
  47. /**
  48. * @brief Marks a function or variable as a weak symbol.
  49. * @note If the compiler does not support such a feature then this macro
  50. * must not be defined or it could originate errors.
  51. */
  52. #define CC_WEAK __attribute__((weak))
  53. /**
  54. * @brief Marks a function or variable as used.
  55. * @details The compiler or linker shall not remove the marked function or
  56. * variable regardless if it is referred or not in the code.
  57. * @note If the compiler does not support such a feature then this macro
  58. * must not be defined or it could originate errors.
  59. */
  60. #define CC_USED __attribute__((used))
  61. /**
  62. * @brief Enforces alignment of the variable or function declared afterward.
  63. * @note If the compiler does not support such a feature then this macro
  64. * must not be defined or it could originate errors.
  65. */
  66. #define CC_ALIGN(n) __attribute__((aligned(n)))
  67. /**
  68. * @brief Enforces packing of the structure declared afterward.
  69. * @note If the compiler does not support such a feature then this macro
  70. * must not be defined or it could originate errors.
  71. */
  72. #define CC_PACK __attribute__((packed))
  73. /**
  74. * @brief Marks a function as not inlineable.
  75. * @note Can be implemented as an empty macro if not supported by the
  76. * compiler.
  77. */
  78. #define CC_NO_INLINE __attribute__((noinline))
  79. /**
  80. * @brief Enforces a function inline.
  81. * @note Can be implemented as an empty macro if not supported by the
  82. * compiler.
  83. */
  84. #define CC_FORCE_INLINE __attribute__((always_inline))
  85. /**
  86. * @brief Marks a function as non-returning.
  87. * @note Can be implemented as an empty macro if not supported by the
  88. * compiler.
  89. */
  90. #define CC_NO_RETURN __attribute__((noreturn))
  91. /** @} */
  92. /*===========================================================================*/
  93. /* External declarations. */
  94. /*===========================================================================*/
  95. #ifdef __cplusplus
  96. extern "C" {
  97. #endif
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. /*===========================================================================*/
  102. /* Module inline functions. */
  103. /*===========================================================================*/
  104. #endif /* CCPORTAB_H */
  105. /** @} */