PulseAudio: gccmacro.h Source File (original) (raw)
1 #ifndef foopulsegccmacrohfoo
2 #define foopulsegccmacrohfoo
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
26 #if defined(__GNUC__)
27 #ifdef __MINGW32__
28 #include <stdio.h>
29 #define PA_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (__MINGW_PRINTF_FORMAT, a, b)))
30 #else
31 #define PA_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
32 #endif
33 #else
35 #define PA_GCC_PRINTF_ATTR(a,b)
36 #endif
37
38 #if defined(__GNUC__) && (__GNUC__ >= 4)
39 #define PA_GCC_SENTINEL __attribute__ ((sentinel))
40 #else
42 #define PA_GCC_SENTINEL
43 #endif
44
45 #ifdef __GNUC__
46 #define PA_GCC_NORETURN __attribute__((noreturn))
47 #else
49 #define PA_GCC_NORETURN
50 #endif
51
52 #ifdef __GNUC__
53 #define PA_GCC_UNUSED __attribute__ ((unused))
54 #else
56 #define PA_GCC_UNUSED
57 #endif
58
59 #ifdef __GNUC__
60 #define PA_GCC_DESTRUCTOR __attribute__ ((destructor))
61 #else
63 #define PA_GCC_DESTRUCTOR
64 #endif
65
66 #ifndef PA_GCC_PURE
67 #ifdef __GNUC__
68 #define PA_GCC_PURE __attribute__ ((pure))
69 #else
71 #define PA_GCC_PURE
72 #endif
73 #endif
74
75 #ifndef PA_GCC_CONST
76 #ifdef __GNUC__
77 #define PA_GCC_CONST __attribute__ ((const))
78 #else
80 #define PA_GCC_CONST
81 #endif
82 #endif
83
84 #ifndef PA_GCC_DEPRECATED
85 #ifdef __GNUC__
86 #define PA_GCC_DEPRECATED __attribute__ ((deprecated))
87 #else
89 #define PA_GCC_DEPRECATED
90 #endif
91 #endif
92
93 #ifndef PA_GCC_PACKED
94 #ifdef __GNUC__
95 #define PA_GCC_PACKED __attribute__ ((packed))
96 #else
98 #define PA_GCC_PACKED
99 #endif
100 #endif
101
102 #ifndef PA_GCC_ALLOC_SIZE
103 #if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
104 #define PA_GCC_ALLOC_SIZE(x) __attribute__ ((__alloc_size__(x)))
105 #define PA_GCC_ALLOC_SIZE2(x,y) __attribute__ ((__alloc_size__(x,y)))
106 #else
108 #define PA_GCC_ALLOC_SIZE(x)
110 #define PA_GCC_ALLOC_SIZE2(x,y)
111 #endif
112 #endif
113
114 #ifndef PA_GCC_MALLOC
115 #ifdef __GNUC__
116 #define PA_GCC_MALLOC __attribute__ ((malloc))
117 #else
119 #define PA_GCC_MALLOC
120 #endif
121 #endif
122
123 #ifndef PA_GCC_WEAKREF
124 #if defined(__GNUC__) && defined(__ELF__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ > 1)) || (__GNUC__ > 4))
126 #define PA_GCC_WEAKREF(x) __attribute__((weakref(#x)))
127 #endif
128 #endif
129
130 #ifndef PA_LIKELY
131 #ifdef __GNUC__
132 #define PA_LIKELY(x) (__builtin_expect(!!(x),1))
133 #define PA_UNLIKELY(x) (__builtin_expect(!!(x),0))
134 #else
135 #define PA_LIKELY(x) (x)
136 #define PA_UNLIKELY(x) (x)
137 #endif
138 #endif
139
140 #ifdef __GNUC__
141 #define PA_CLAMP(x, low, high) \
142 __extension__ ({ \
143 typeof(x) _x = (x); \
144 typeof(low) _low = (low); \
145 typeof(high) _high = (high); \
146 ((_x > _high) ? _high : ((_x < _low) ? _low : _x)); \
147 })
148 #else
149 #define PA_CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
150 #endif
151
152 #ifdef __GNUC__
153 #define PA_CLAMP_UNLIKELY(x, low, high) \
154 __extension__ ({ \
155 typeof(x) _x = (x); \
156 typeof(low) _low = (low); \
157 typeof(high) _high = (high); \
158 (PA_UNLIKELY(_x > _high) ? _high : (PA_UNLIKELY(_x < _low) ? _low : _x)); \
159 })
160 #else
161 #define PA_CLAMP_UNLIKELY(x, low, high) (PA_UNLIKELY((x) > (high)) ? (high) : (PA_UNLIKELY((x) < (low)) ? (low) : (x)))
162 #endif
163
164
165
166
167
168 #endif