Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

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