Commit | Line | Data |
---|---|---|
2791730d MR |
1 | /* |
2 | * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | |
3 | * | |
2912e87a | 4 | * This file is part of Libav. |
2791730d | 5 | * |
2912e87a | 6 | * Libav is free software; you can redistribute it and/or |
2791730d MR |
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 | * | |
2912e87a | 11 | * Libav is distributed in the hope that it will be useful, |
2791730d MR |
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 | |
2912e87a | 17 | * License along with Libav; if not, write to the Free Software |
2791730d MR |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | */ | |
20 | ||
21 | /** | |
ba87f080 | 22 | * @file |
2791730d MR |
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 | ||
2791730d MR |
35 | #if AV_GCC_VERSION_AT_LEAST(3,1) |
36 | # define av_always_inline __attribute__((always_inline)) inline | |
4f2c846d RB |
37 | #elif defined(_MSC_VER) |
38 | # define av_always_inline __forceinline | |
2791730d MR |
39 | #else |
40 | # define av_always_inline inline | |
41 | #endif | |
2791730d | 42 | |
2791730d MR |
43 | #if AV_GCC_VERSION_AT_LEAST(3,1) |
44 | # define av_noinline __attribute__((noinline)) | |
45 | #else | |
46 | # define av_noinline | |
47 | #endif | |
2791730d | 48 | |
2791730d MR |
49 | #if AV_GCC_VERSION_AT_LEAST(3,1) |
50 | # define av_pure __attribute__((pure)) | |
51 | #else | |
52 | # define av_pure | |
53 | #endif | |
2791730d | 54 | |
2791730d MR |
55 | #if AV_GCC_VERSION_AT_LEAST(2,6) |
56 | # define av_const __attribute__((const)) | |
57 | #else | |
58 | # define av_const | |
59 | #endif | |
2791730d | 60 | |
820818a3 | 61 | #if AV_GCC_VERSION_AT_LEAST(4,3) |
2791730d MR |
62 | # define av_cold __attribute__((cold)) |
63 | #else | |
64 | # define av_cold | |
65 | #endif | |
2791730d | 66 | |
820818a3 | 67 | #if AV_GCC_VERSION_AT_LEAST(4,1) |
2791730d MR |
68 | # define av_flatten __attribute__((flatten)) |
69 | #else | |
70 | # define av_flatten | |
71 | #endif | |
2791730d | 72 | |
2791730d MR |
73 | #if AV_GCC_VERSION_AT_LEAST(3,1) |
74 | # define attribute_deprecated __attribute__((deprecated)) | |
09f2581d AS |
75 | #elif defined(_MSC_VER) |
76 | # define attribute_deprecated __declspec(deprecated) | |
2791730d MR |
77 | #else |
78 | # define attribute_deprecated | |
79 | #endif | |
2791730d | 80 | |
2791730d MR |
81 | #if defined(__GNUC__) |
82 | # define av_unused __attribute__((unused)) | |
83 | #else | |
84 | # define av_unused | |
85 | #endif | |
2791730d | 86 | |
365e3c78 MR |
87 | /** |
88 | * Mark a variable as used and prevent the compiler from optimizing it | |
89 | * away. This is useful for variables accessed only from inline | |
90 | * assembler without the compiler being aware. | |
91 | */ | |
365e3c78 MR |
92 | #if AV_GCC_VERSION_AT_LEAST(3,1) |
93 | # define av_used __attribute__((used)) | |
94 | #else | |
95 | # define av_used | |
96 | #endif | |
365e3c78 | 97 | |
820818a3 | 98 | #if AV_GCC_VERSION_AT_LEAST(3,3) |
a74d707c MN |
99 | # define av_alias __attribute__((may_alias)) |
100 | #else | |
101 | # define av_alias | |
102 | #endif | |
a74d707c | 103 | |
2791730d MR |
104 | #if defined(__GNUC__) && !defined(__ICC) |
105 | # define av_uninit(x) x=x | |
106 | #else | |
107 | # define av_uninit(x) x | |
108 | #endif | |
2791730d | 109 | |
4ed39eed MN |
110 | #ifdef __GNUC__ |
111 | # define av_builtin_constant_p __builtin_constant_p | |
67e9ae14 | 112 | # define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos))) |
4ed39eed MN |
113 | #else |
114 | # define av_builtin_constant_p(x) 0 | |
67e9ae14 | 115 | # define av_printf_format(fmtpos, attrpos) |
4ed39eed MN |
116 | #endif |
117 | ||
22662ca5 RT |
118 | #if AV_GCC_VERSION_AT_LEAST(2,5) |
119 | # define av_noreturn __attribute__((noreturn)) | |
120 | #else | |
121 | # define av_noreturn | |
122 | #endif | |
123 | ||
2791730d | 124 | #endif /* AVUTIL_ATTRIBUTES_H */ |