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.

163 lines
4.3KB

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