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