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