Libav
attributes.h
Go to the documentation of this file.
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 
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 #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
42 
43 #if AV_GCC_VERSION_AT_LEAST(3,1)
44 # define av_noinline __attribute__((noinline))
45 #elif defined(_MSC_VER)
46 # define av_noinline __declspec(noinline)
47 #else
48 # define av_noinline
49 #endif
50 
51 #if AV_GCC_VERSION_AT_LEAST(3,1)
52 # define av_pure __attribute__((pure))
53 #else
54 # define av_pure
55 #endif
56 
57 #if AV_GCC_VERSION_AT_LEAST(2,6)
58 # define av_const __attribute__((const))
59 #else
60 # define av_const
61 #endif
62 
63 #if AV_GCC_VERSION_AT_LEAST(4,3)
64 # define av_cold __attribute__((cold))
65 #else
66 # define av_cold
67 #endif
68 
69 #if AV_GCC_VERSION_AT_LEAST(4,1) && !defined(__llvm__)
70 # define av_flatten __attribute__((flatten))
71 #else
72 # define av_flatten
73 #endif
74 
75 #if AV_GCC_VERSION_AT_LEAST(3,1)
76 # define attribute_deprecated __attribute__((deprecated))
77 #elif defined(_MSC_VER)
78 # define attribute_deprecated __declspec(deprecated)
79 #else
80 # define attribute_deprecated
81 #endif
82 
83 #if defined(__GNUC__)
84 # define av_unused __attribute__((unused))
85 #else
86 # define av_unused
87 #endif
88 
94 #if AV_GCC_VERSION_AT_LEAST(3,1)
95 # define av_used __attribute__((used))
96 #else
97 # define av_used
98 #endif
99 
100 #if AV_GCC_VERSION_AT_LEAST(3,3)
101 # define av_alias __attribute__((may_alias))
102 #else
103 # define av_alias
104 #endif
105 
106 #if defined(__GNUC__) && !defined(__ICC)
107 # define av_uninit(x) x=x
108 #else
109 # define av_uninit(x) x
110 #endif
111 
112 #ifdef __GNUC__
113 # define av_builtin_constant_p __builtin_constant_p
114 # define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
115 #else
116 # define av_builtin_constant_p(x) 0
117 # define av_printf_format(fmtpos, attrpos)
118 #endif
119 
120 #if AV_GCC_VERSION_AT_LEAST(2,5)
121 # define av_noreturn __attribute__((noreturn))
122 #else
123 # define av_noreturn
124 #endif
125 
126 #endif /* AVUTIL_ATTRIBUTES_H */