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
23 * Macro definitions for various function/variable attributes
26 #ifndef AVUTIL_ATTRIBUTES_H
27 #define AVUTIL_ATTRIBUTES_H
30 # define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y)
32 # define AV_GCC_VERSION_AT_LEAST(x,y) 0
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
40 # define av_always_inline inline
43 #if AV_GCC_VERSION_AT_LEAST(3,1)
44 # define av_noinline __attribute__((noinline))
49 #if AV_GCC_VERSION_AT_LEAST(3,1)
50 # define av_pure __attribute__((pure))
55 #if AV_GCC_VERSION_AT_LEAST(2,6)
56 # define av_const __attribute__((const))
61 #if AV_GCC_VERSION_AT_LEAST(4,3)
62 # define av_cold __attribute__((cold))
67 #if AV_GCC_VERSION_AT_LEAST(4,1)
68 # define av_flatten __attribute__((flatten))
73 #if AV_GCC_VERSION_AT_LEAST(3,1)
74 # define attribute_deprecated __attribute__((deprecated))
76 # define attribute_deprecated
80 # define av_unused __attribute__((unused))
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))
96 #if AV_GCC_VERSION_AT_LEAST(3,3)
97 # define av_alias __attribute__((may_alias))
102 #if defined(__GNUC__) && !defined(__ICC)
103 # define av_uninit(x) x=x
105 # define av_uninit(x) x
109 # define av_builtin_constant_p __builtin_constant_p
110 # define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
112 # define av_builtin_constant_p(x) 0
113 # define av_printf_format(fmtpos, attrpos)
116 #if AV_GCC_VERSION_AT_LEAST(2,5)
117 # define av_noreturn __attribute__((noreturn))
122 #endif /* AVUTIL_ATTRIBUTES_H */