985ebd23eac586c83f230404ed72782855b5333c
[paraslash.git] / gcc-compat.h
1 #if __GNUC__ >= 3
2 # define inline inline __attribute__ ((always_inline))
3 # define __noreturn __attribute__ ((noreturn))
4 # define __malloc __attribute__ ((malloc))
5 # define __used __attribute__ ((used))
6 # define __a_unused __attribute__ ((unused))
7 # define __packed __attribute__ ((packed))
8 # define likely(x) __builtin_expect (!!(x), 1)
9 # define unlikely(x) __builtin_expect (!!(x), 0)
10 /*
11 * p is the number of the "format string" parameter, and q is
12 * the number of the first variadic parameter
13 */
14 # define __printf(p,q) __attribute__ ((format (printf, p, q)))
15 /*
16 * as direct use of __printf(p,q) confuses doxygen, here are two extra macros
17 * for those values p,q that are actually used by paraslash.
18 */
19 #define __printf_1_2 __printf(1,2)
20 #define __printf_2_3 __printf(2,3)
21
22 #else
23
24 # define inline /* no inline */
25 # define __noreturn /* no noreturn */
26 # define __malloc /* no malloc */
27 # define __used /* no used */
28 # define __a_unused /* no unused */
29 # define __packed /* no packed */
30 # define likely(x) (x)
31 # define unlikely(x) (x)
32 # define __printf(p,q) /* no format */
33 #define __printf_1_2
34 #define __printf_2_3
35 #endif
36
37 # if __GNUC__ >=3 && __GNUC_MINOR__ > 3
38 # define __must_check __attribute__ ((warn_unused_result))
39 # else
40 # define __must_check /* no warn_unused_result */
41 # endif