]> git.sesse.net Git - ffmpeg/blob - libavutil/attributes.h
opt/eval: Include mathematics.h for NAN/INFINITY
[ffmpeg] / libavutil / attributes.h
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 /**
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_noinline
46 #if AV_GCC_VERSION_AT_LEAST(3,1)
47 #    define av_noinline __attribute__((noinline))
48 #else
49 #    define av_noinline
50 #endif
51 #endif
52
53 #ifndef av_pure
54 #if AV_GCC_VERSION_AT_LEAST(3,1)
55 #    define av_pure __attribute__((pure))
56 #else
57 #    define av_pure
58 #endif
59 #endif
60
61 #ifndef av_const
62 #if AV_GCC_VERSION_AT_LEAST(2,6)
63 #    define av_const __attribute__((const))
64 #else
65 #    define av_const
66 #endif
67 #endif
68
69 #ifndef av_cold
70 #if AV_GCC_VERSION_AT_LEAST(4,3)
71 #    define av_cold __attribute__((cold))
72 #else
73 #    define av_cold
74 #endif
75 #endif
76
77 #ifndef av_flatten
78 #if AV_GCC_VERSION_AT_LEAST(4,1)
79 #    define av_flatten __attribute__((flatten))
80 #else
81 #    define av_flatten
82 #endif
83 #endif
84
85 #ifndef attribute_deprecated
86 #if AV_GCC_VERSION_AT_LEAST(3,1)
87 #    define attribute_deprecated __attribute__((deprecated))
88 #else
89 #    define attribute_deprecated
90 #endif
91 #endif
92
93 #ifndef av_unused
94 #if defined(__GNUC__)
95 #    define av_unused __attribute__((unused))
96 #else
97 #    define av_unused
98 #endif
99 #endif
100
101 /**
102  * Mark a variable as used and prevent the compiler from optimizing it
103  * away.  This is useful for variables accessed only from inline
104  * assembler without the compiler being aware.
105  */
106 #ifndef av_used
107 #if AV_GCC_VERSION_AT_LEAST(3,1)
108 #    define av_used __attribute__((used))
109 #else
110 #    define av_used
111 #endif
112 #endif
113
114 #ifndef av_alias
115 #if AV_GCC_VERSION_AT_LEAST(3,3)
116 #   define av_alias __attribute__((may_alias))
117 #else
118 #   define av_alias
119 #endif
120 #endif
121
122 #ifndef av_uninit
123 #if defined(__GNUC__) && !defined(__ICC)
124 #    define av_uninit(x) x=x
125 #else
126 #    define av_uninit(x) x
127 #endif
128 #endif
129
130 #ifdef __GNUC__
131 #    define av_builtin_constant_p __builtin_constant_p
132 #    define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
133 #else
134 #    define av_builtin_constant_p(x) 0
135 #    define av_printf_format(fmtpos, attrpos)
136 #endif
137
138 #endif /* AVUTIL_ATTRIBUTES_H */