1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#define QEMU_GNUC_PREREQ(maj, min) 1
23#define QEMU_NORETURN __attribute__ ((__noreturn__))
24#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
25#define QEMU_SENTINEL __attribute__((sentinel))
26
27#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
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] __attribute__((unused));
37
38#define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
39
40#define xglue(x, y) x ## y
41#define glue(x, y) xglue(x, y)
42#define stringify(s) tostring(s)
43#define tostring(s) #s
44
45#define typeof_field(type, field) typeof(((type *)0)->field)
46#define type_check(t1,t2) ((t1*)0 - (t2*)0)
47
48
49
50#define QLIST_HEAD(name, type) \
51struct name { \
52 struct type *lh_first; \
53}
54
55#define QLIST_HEAD_INITIALIZER(head) \
56 { NULL }
57
58#define QLIST_ENTRY(type) \
59struct { \
60 struct type *le_next; \
61 struct type **le_prev; \
62}
63
64
65
66
67#define QSLIST_HEAD(name, type) \
68struct name { \
69 struct type *slh_first; \
70}
71
72#define QSLIST_HEAD_INITIALIZER(head) \
73 { NULL }
74
75#define QSLIST_ENTRY(type) \
76struct { \
77 struct type *sle_next; \
78}
79
80
81
82
83#define QSIMPLEQ_HEAD(name, type) \
84struct name { \
85 struct type *sqh_first; \
86 struct type **sqh_last; \
87}
88
89#define QSIMPLEQ_HEAD_INITIALIZER(head) \
90 { NULL, &(head).sqh_first }
91
92#define QSIMPLEQ_ENTRY(type) \
93struct { \
94 struct type *sqe_next; \
95}
96
97
98
99
100#define QTAILQ_HEAD(name, type) \
101union name { \
102 struct type *tqh_first; \
103 QTailQLink tqh_circ; \
104}
105
106#define QTAILQ_HEAD_INITIALIZER(head) \
107 { .tqh_circ = { NULL, &(head).tqh_circ } }
108
109#define QTAILQ_ENTRY(type) \
110union { \
111 struct type *tqe_next; \
112 QTailQLink tqe_circ; \
113}
114
115
116#define g_assert_cmpint(a, op, b) g_assert(a op b)
117#define g_assert_cmpuint(a, op, b) g_assert(a op b)
118#define g_assert_cmphex(a, op, b) g_assert(a op b)
119#define g_assert_cmpstr(a, op, b) g_assert(strcmp(a, b) op 0)
120