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.

127 lines
3.4KB

  1. /*
  2. * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav 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. * Libav 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 Libav; 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. #if AV_GCC_VERSION_AT_LEAST(3,1)
  32. # define av_always_inline __attribute__((always_inline)) inline
  33. #elif defined(_MSC_VER)
  34. # define av_always_inline __forceinline
  35. #else
  36. # define av_always_inline inline
  37. #endif
  38. #if AV_GCC_VERSION_AT_LEAST(3,1)
  39. # define av_noinline __attribute__((noinline))
  40. #elif defined(_MSC_VER)
  41. # define av_noinline __declspec(noinline)
  42. #else
  43. # define av_noinline
  44. #endif
  45. #if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
  46. # define av_pure __attribute__((pure))
  47. #else
  48. # define av_pure
  49. #endif
  50. #if AV_GCC_VERSION_AT_LEAST(2,6) || defined(__clang__)
  51. # define av_const __attribute__((const))
  52. #else
  53. # define av_const
  54. #endif
  55. #if AV_GCC_VERSION_AT_LEAST(4,3) || defined(__clang__)
  56. # define av_cold __attribute__((cold))
  57. #else
  58. # define av_cold
  59. #endif
  60. #if AV_GCC_VERSION_AT_LEAST(4,1) && !defined(__llvm__)
  61. # define av_flatten __attribute__((flatten))
  62. #else
  63. # define av_flatten
  64. #endif
  65. #if AV_GCC_VERSION_AT_LEAST(3,1)
  66. # define attribute_deprecated __attribute__((deprecated))
  67. #elif defined(_MSC_VER)
  68. # define attribute_deprecated __declspec(deprecated)
  69. #else
  70. # define attribute_deprecated
  71. #endif
  72. #if defined(__GNUC__) || defined(__clang__)
  73. # define av_unused __attribute__((unused))
  74. #else
  75. # define av_unused
  76. #endif
  77. /**
  78. * Mark a variable as used and prevent the compiler from optimizing it
  79. * away. This is useful for variables accessed only from inline
  80. * assembler without the compiler being aware.
  81. */
  82. #if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
  83. # define av_used __attribute__((used))
  84. #else
  85. # define av_used
  86. #endif
  87. #if AV_GCC_VERSION_AT_LEAST(3,3) || defined(__clang__)
  88. # define av_alias __attribute__((may_alias))
  89. #else
  90. # define av_alias
  91. #endif
  92. #if (defined(__GNUC__) || defined(__clang__)) && !defined(__ICC)
  93. # define av_uninit(x) x=x
  94. #else
  95. # define av_uninit(x) x
  96. #endif
  97. #if defined(__GNUC__) || defined(__clang__)
  98. # define av_builtin_constant_p __builtin_constant_p
  99. # define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
  100. #else
  101. # define av_builtin_constant_p(x) 0
  102. # define av_printf_format(fmtpos, attrpos)
  103. #endif
  104. #if AV_GCC_VERSION_AT_LEAST(2,5) || defined(__clang__)
  105. # define av_noreturn __attribute__((noreturn))
  106. #else
  107. # define av_noreturn
  108. #endif
  109. #endif /* AVUTIL_ATTRIBUTES_H */