summaryrefslogtreecommitdiff
path: root/gcc-compat.h
blob: fb948779065bb9c34dc5b8ba4dbc975d610b5ae8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* SPDX-License-Identifier: GPL-2.0 */

#define HAVE_GNUC(maj, min) \
	defined(__GNUC__) && \
	(__GNUC__ > maj || (__GNUC__ == maj && __GNUC_MINOR__ >= min))

#if HAVE_GNUC(3,0)
# define __malloc	__attribute__ ((malloc))
#else
# define __malloc
#endif

/*
 * p is the number of the "format string" parameter, and q is
 * the number of the first variadic parameter.
 */
#if HAVE_GNUC(2,3)
# define __printf(p,q) __attribute__ ((format (printf, p, q)))
#else
# define __printf(p,q)
#endif

#define  __printf_1_2 __printf(1,2)
#define  __printf_2_3 __printf(2,3)

#if HAVE_GNUC(3,3)
# define __must_check	__attribute__ ((warn_unused_result))
#else
# define __must_check	/* no warn_unused_result */
#endif