You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
4.1KB

  1. /*
  2. * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /**
  21. * @file
  22. * Macro definitions for various function/variable attributes
  23. */
  24. #ifndef AVUTIL_ATTRIBUTES_H
  25. #define AVUTIL_ATTRIBUTES_H
  26. #ifdef __GNUC__
  27. # define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y)
  28. #else
  29. # define AV_GCC_VERSION_AT_LEAST(x,y) 0
  30. #endif
  31. #ifndef av_always_inline
  32. #if AV_GCC_VERSION_AT_LEAST(3,1)
  33. # define av_always_inline __attribute__((always_inline)) inline
  34. #elif defined(_MSC_VER)
  35. # define av_always_inline __forceinline
  36. #else
  37. # define av_always_inline inline
  38. #endif
  39. #endif
  40. #ifndef av_extern_inline
  41. #if defined(__ICL) && __ICL >= 1210 || defined(__GNUC_STDC_INLINE__)
  42. # define av_extern_inline extern inline
  43. #else
  44. # define av_extern_inline inline
  45. #endif
  46. #endif
  47. #ifndef av_noreturn
  48. #if AV_GCC_VERSION_AT_LEAST(2,5)
  49. # define av_noreturn __attribute__((noreturn))
  50. #else
  51. # define av_noreturn
  52. #endif
  53. #endif
  54. #ifndef av_noinline
  55. #if AV_GCC_VERSION_AT_LEAST(3,1)
  56. # define av_noinline __attribute__((noinline))
  57. #else
  58. # define av_noinline
  59. #endif
  60. #endif
  61. #ifndef av_pure
  62. #if AV_GCC_VERSION_AT_LEAST(3,1)
  63. # define av_pure __attribute__((pure))
  64. #else
  65. # define av_pure
  66. #endif
  67. #endif
  68. #ifndef av_restrict
  69. #define av_restrict restrict
  70. #endif
  71. #ifndef av_const
  72. #if AV_GCC_VERSION_AT_LEAST(2,6)
  73. # define av_const __attribute__((const))
  74. #else
  75. # define av_const
  76. #endif
  77. #endif
  78. #ifndef av_cold
  79. #if AV_GCC_VERSION_AT_LEAST(4,3)
  80. # define av_cold __attribute__((cold))
  81. #else
  82. # define av_cold
  83. #endif
  84. #endif
  85. #ifndef av_flatten
  86. #if AV_GCC_VERSION_AT_LEAST(4,1)
  87. # define av_flatten __attribute__((flatten))
  88. #else
  89. # define av_flatten
  90. #endif
  91. #endif
  92. #ifndef attribute_deprecated
  93. #if AV_GCC_VERSION_AT_LEAST(3,1)
  94. # define attribute_deprecated __attribute__((deprecated))
  95. #else
  96. # define attribute_deprecated
  97. #endif
  98. #endif
  99. /**
  100. * Disable warnings about deprecated features
  101. * This is useful for sections of code kept for backward compatibility and
  102. * scheduled for removal.
  103. */
  104. #ifndef AV_NOWARN_DEPRECATED
  105. #if AV_GCC_VERSION_AT_LEAST(4,6)
  106. # define AV_NOWARN_DEPRECATED(code) \
  107. _Pragma("GCC diagnostic push") \
  108. _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
  109. code \
  110. _Pragma("GCC diagnostic pop")
  111. #else
  112. # define AV_NOWARN_DEPRECATED(code) code
  113. #endif
  114. #endif
  115. #ifndef av_unused
  116. #if defined(__GNUC__)
  117. # define av_unused __attribute__((unused))
  118. #else
  119. # define av_unused
  120. #endif
  121. #endif
  122. /**
  123. * Mark a variable as used and prevent the compiler from optimizing it
  124. * away. This is useful for variables accessed only from inline
  125. * assembler without the compiler being aware.
  126. */
  127. #ifndef av_used
  128. #if AV_GCC_VERSION_AT_LEAST(3,1)
  129. # define av_used __attribute__((used))
  130. #else
  131. # define av_used
  132. #endif
  133. #endif
  134. #ifndef av_alias
  135. #if AV_GCC_VERSION_AT_LEAST(3,3)
  136. # define av_alias __attribute__((may_alias))
  137. #else
  138. # define av_alias
  139. #endif
  140. #endif
  141. #ifndef av_uninit
  142. #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
  143. # define av_uninit(x) x=x
  144. #else
  145. # define av_uninit(x) x
  146. #endif
  147. #endif
  148. #ifdef __GNUC__
  149. # define av_builtin_constant_p __builtin_constant_p
  150. # define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
  151. #else
  152. # define av_builtin_constant_p(x) 0
  153. # define av_printf_format(fmtpos, attrpos)
  154. #endif
  155. #endif /* AVUTIL_ATTRIBUTES_H */