h264: on reference overflow, reset the reference count to 0, not 1.
[FFMpeg-mirror/mplayer-patches.git] / libavutil / attributes.h
blob292a0a1a88f095e80e33dcb2b3e3bd3102f6542f
1 /*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
4 * This file is part of Libav.
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.
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.
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
21 /**
22 * @file
23 * Macro definitions for various function/variable attributes
26 #ifndef AVUTIL_ATTRIBUTES_H
27 #define AVUTIL_ATTRIBUTES_H
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
35 #if AV_GCC_VERSION_AT_LEAST(3,1)
36 # define av_always_inline __attribute__((always_inline)) inline
37 #elif defined(_MSC_VER)
38 # define av_always_inline __forceinline
39 #else
40 # define av_always_inline inline
41 #endif
43 #if AV_GCC_VERSION_AT_LEAST(3,1)
44 # define av_noinline __attribute__((noinline))
45 #else
46 # define av_noinline
47 #endif
49 #if AV_GCC_VERSION_AT_LEAST(3,1)
50 # define av_pure __attribute__((pure))
51 #else
52 # define av_pure
53 #endif
55 #if AV_GCC_VERSION_AT_LEAST(2,6)
56 # define av_const __attribute__((const))
57 #else
58 # define av_const
59 #endif
61 #if AV_GCC_VERSION_AT_LEAST(4,3)
62 # define av_cold __attribute__((cold))
63 #else
64 # define av_cold
65 #endif
67 #if AV_GCC_VERSION_AT_LEAST(4,1)
68 # define av_flatten __attribute__((flatten))
69 #else
70 # define av_flatten
71 #endif
73 #if AV_GCC_VERSION_AT_LEAST(3,1)
74 # define attribute_deprecated __attribute__((deprecated))
75 #else
76 # define attribute_deprecated
77 #endif
79 #if defined(__GNUC__)
80 # define av_unused __attribute__((unused))
81 #else
82 # define av_unused
83 #endif
85 /**
86 * Mark a variable as used and prevent the compiler from optimizing it
87 * away. This is useful for variables accessed only from inline
88 * assembler without the compiler being aware.
90 #if AV_GCC_VERSION_AT_LEAST(3,1)
91 # define av_used __attribute__((used))
92 #else
93 # define av_used
94 #endif
96 #if AV_GCC_VERSION_AT_LEAST(3,3)
97 # define av_alias __attribute__((may_alias))
98 #else
99 # define av_alias
100 #endif
102 #if defined(__GNUC__) && !defined(__ICC)
103 # define av_uninit(x) x=x
104 #else
105 # define av_uninit(x) x
106 #endif
108 #ifdef __GNUC__
109 # define av_builtin_constant_p __builtin_constant_p
110 # define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
111 #else
112 # define av_builtin_constant_p(x) 0
113 # define av_printf_format(fmtpos, attrpos)
114 #endif
116 #if AV_GCC_VERSION_AT_LEAST(2,5)
117 # define av_noreturn __attribute__((noreturn))
118 #else
119 # define av_noreturn
120 #endif
122 #endif /* AVUTIL_ATTRIBUTES_H */