1
2
3#ifndef COMPILER_H
4#define COMPILER_H
5
6#include "config-host.h"
7
8
9
10
11
12#if defined(__GNUC__) && defined(__GNUC_MINOR__)
13# define QEMU_GNUC_PREREQ(maj, min) \
14 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
15#else
16# define QEMU_GNUC_PREREQ(maj, min) 0
17#endif
18
19#define QEMU_NORETURN __attribute__ ((__noreturn__))
20
21#if QEMU_GNUC_PREREQ(3, 4)
22#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
23#else
24#define QEMU_WARN_UNUSED_RESULT
25#endif
26
27#if defined(_WIN32)
28# define QEMU_PACKED __attribute__((gcc_struct, packed))
29#else
30# define QEMU_PACKED __attribute__((packed))
31#endif
32
33#define cat(x,y) x ## y
34#define cat2(x,y) cat(x,y)
35#define QEMU_BUILD_BUG_ON(x) \
36 typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1];
37
38#if defined __GNUC__
39# if !QEMU_GNUC_PREREQ(4, 4)
40
41# define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2)))
42# define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
43# else
44
45# define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2)))
46# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
47# if defined(_WIN32)
48
49
50# define __printf__ __gnu_printf__
51# endif
52# endif
53#else
54#define GCC_ATTR
55#define GCC_FMT_ATTR(n, m)
56#endif
57
58#endif
59