]> git.sesse.net Git - casparcg/blob - ffmpeg 0.8/include/libavutil/attributes.h
(no commit message)
[casparcg] / ffmpeg 0.8 / include / libavutil / attributes.h
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 #else
39 #    define av_always_inline inline
40 #endif
41 #endif
42
43 #ifndef av_noreturn
44 #if AV_GCC_VERSION_AT_LEAST(2,5)
45 #    define av_noreturn __attribute__((noreturn))
46 #else
47 #    define av_noreturn
48 #endif
49 #endif
50
51 #ifndef av_noinline
52 #if AV_GCC_VERSION_AT_LEAST(3,1)
53 #    define av_noinline __attribute__((noinline))
54 #else
55 #    define av_noinline
56 #endif
57 #endif
58
59 #ifndef av_pure
60 #if AV_GCC_VERSION_AT_LEAST(3,1)
61 #    define av_pure __attribute__((pure))
62 #else
63 #    define av_pure
64 #endif
65 #endif
66
67 #ifndef av_const
68 #if AV_GCC_VERSION_AT_LEAST(2,6)
69 #    define av_const __attribute__((const))
70 #else
71 #    define av_const
72 #endif
73 #endif
74
75 #ifndef av_cold
76 #if AV_GCC_VERSION_AT_LEAST(4,3)
77 #    define av_cold __attribute__((cold))
78 #else
79 #    define av_cold
80 #endif
81 #endif
82
83 #ifndef av_flatten
84 #if AV_GCC_VERSION_AT_LEAST(4,1)
85 #    define av_flatten __attribute__((flatten))
86 #else
87 #    define av_flatten
88 #endif
89 #endif
90
91 #ifndef attribute_deprecated
92 #if AV_GCC_VERSION_AT_LEAST(3,1)
93 #    define attribute_deprecated __attribute__((deprecated))
94 #else
95 #    define attribute_deprecated
96 #endif
97 #endif
98
99 /**
100  * Disable warnings about deprecated features
101  * This is useful for sections of code kept for backward compatibility and
102  * scheduled for removal.
103  */
104 #ifndef AV_NOWARN_DEPRECATED
105 #if AV_GCC_VERSION_AT_LEAST(4,6)
106 #    define AV_NOWARN_DEPRECATED(code) \
107         _Pragma("GCC diagnostic push") \
108         _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
109         code \
110         _Pragma("GCC diagnostic pop")
111 #else
112 #    define AV_NOWARN_DEPRECATED(code) code
113 #endif
114 #endif
115
116
117 #ifndef av_unused
118 #if defined(__GNUC__)
119 #    define av_unused __attribute__((unused))
120 #else
121 #    define av_unused
122 #endif
123 #endif
124
125 /**
126  * Mark a variable as used and prevent the compiler from optimizing it
127  * away.  This is useful for variables accessed only from inline
128  * assembler without the compiler being aware.
129  */
130 #ifndef av_used
131 #if AV_GCC_VERSION_AT_LEAST(3,1)
132 #    define av_used __attribute__((used))
133 #else
134 #    define av_used
135 #endif
136 #endif
137
138 #ifndef av_alias
139 #if AV_GCC_VERSION_AT_LEAST(3,3)
140 #   define av_alias __attribute__((may_alias))
141 #else
142 #   define av_alias
143 #endif
144 #endif
145
146 #ifndef av_uninit
147 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
148 #    define av_uninit(x) x=x
149 #else
150 #    define av_uninit(x) x
151 #endif
152 #endif
153
154 #ifdef __GNUC__
155 #    define av_builtin_constant_p __builtin_constant_p
156 #    define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
157 #else
158 #    define av_builtin_constant_p(x) 0
159 #    define av_printf_format(fmtpos, attrpos)
160 #endif
161
162 #endif /* AVUTIL_ATTRIBUTES_H */