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.

175 lines
4.0KB

  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. #else
  35. # define av_always_inline inline
  36. #endif
  37. #endif
  38. #ifndef av_extern_inline
  39. #if defined(__ICL) && __ICL >= 1210 || defined(__GNUC_STDC_INLINE__)
  40. # define av_extern_inline extern inline
  41. #else
  42. # define av_extern_inline inline
  43. #endif
  44. #endif
  45. #ifndef av_noreturn
  46. #if AV_GCC_VERSION_AT_LEAST(2,5)
  47. # define av_noreturn __attribute__((noreturn))
  48. #else
  49. # define av_noreturn
  50. #endif
  51. #endif
  52. #ifndef av_noinline
  53. #if AV_GCC_VERSION_AT_LEAST(3,1)
  54. # define av_noinline __attribute__((noinline))
  55. #else
  56. # define av_noinline
  57. #endif
  58. #endif
  59. #ifndef av_pure
  60. #if AV_GCC_VERSION_AT_LEAST(3,1)
  61. # define av_pure __attribute__((pure))
  62. #else
  63. # define av_pure
  64. #endif
  65. #endif
  66. #ifndef av_restrict
  67. #define av_restrict restrict
  68. #endif
  69. #ifndef av_const
  70. #if AV_GCC_VERSION_AT_LEAST(2,6)
  71. # define av_const __attribute__((const))
  72. #else
  73. # define av_const
  74. #endif
  75. #endif
  76. #ifndef av_cold
  77. #if AV_GCC_VERSION_AT_LEAST(4,3)
  78. # define av_cold __attribute__((cold))
  79. #else
  80. # define av_cold
  81. #endif
  82. #endif
  83. #ifndef av_flatten
  84. #if AV_GCC_VERSION_AT_LEAST(4,1)
  85. # define av_flatten __attribute__((flatten))
  86. #else
  87. # define av_flatten
  88. #endif
  89. #endif
  90. #ifndef attribute_deprecated
  91. #if AV_GCC_VERSION_AT_LEAST(3,1)
  92. # define attribute_deprecated __attribute__((deprecated))
  93. #else
  94. # define attribute_deprecated
  95. #endif
  96. #endif
  97. /**
  98. * Disable warnings about deprecated features
  99. * This is useful for sections of code kept for backward compatibility and
  100. * scheduled for removal.
  101. */
  102. #ifndef AV_NOWARN_DEPRECATED
  103. #if AV_GCC_VERSION_AT_LEAST(4,6)
  104. # define AV_NOWARN_DEPRECATED(code) \
  105. _Pragma("GCC diagnostic push") \
  106. _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
  107. code \
  108. _Pragma("GCC diagnostic pop")
  109. #else
  110. # define AV_NOWARN_DEPRECATED(code) code
  111. #endif
  112. #endif
  113. #ifndef av_unused
  114. #if defined(__GNUC__)
  115. # define av_unused __attribute__((unused))
  116. #else
  117. # define av_unused
  118. #endif
  119. #endif
  120. /**
  121. * Mark a variable as used and prevent the compiler from optimizing it
  122. * away. This is useful for variables accessed only from inline
  123. * assembler without the compiler being aware.
  124. */
  125. #ifndef av_used
  126. #if AV_GCC_VERSION_AT_LEAST(3,1)
  127. # define av_used __attribute__((used))
  128. #else
  129. # define av_used
  130. #endif
  131. #endif
  132. #ifndef av_alias
  133. #if AV_GCC_VERSION_AT_LEAST(3,3)
  134. # define av_alias __attribute__((may_alias))
  135. #else
  136. # define av_alias
  137. #endif
  138. #endif
  139. #ifndef av_uninit
  140. #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
  141. # define av_uninit(x) x=x
  142. #else
  143. # define av_uninit(x) x
  144. #endif
  145. #endif
  146. #ifdef __GNUC__
  147. # define av_builtin_constant_p __builtin_constant_p
  148. # define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
  149. #else
  150. # define av_builtin_constant_p(x) 0
  151. # define av_printf_format(fmtpos, attrpos)
  152. #endif
  153. #endif /* AVUTIL_ATTRIBUTES_H */