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#define QEMU_ARTIFICIAL __attribute__((always_inline, artificial))
27#define QEMU_PACKED __attribute__((gcc_struct, packed))
28
29#define cat(x,y) x ## y
30#define cat2(x,y) cat(x,y)
31#define QEMU_BUILD_BUG_ON(x) \
32 typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1] __attribute__((unused));
33
34#define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
35
36#define xglue(x, y) x ## y
37#define glue(x, y) xglue(x, y)
38#define stringify(s) tostring(s)
39#define tostring(s) #s
40
41#define typeof_field(type, field) typeof(((type *)0)->field)
42#define type_check(t1,t2) ((t1*)0 - (t2*)0)
43
44
45
46#define QLIST_HEAD(name, type) \
47struct name { \
48 struct type *lh_first; \
49}
50
51#define QLIST_HEAD_INITIALIZER(head) \
52 { NULL }
53
54#define QLIST_ENTRY(type) \
55struct { \
56 struct type *le_next; \
57 struct type **le_prev; \
58}
59
60
61
62
63#define QSLIST_HEAD(name, type) \
64struct name { \
65 struct type *slh_first; \
66}
67
68#define QSLIST_HEAD_INITIALIZER(head) \
69 { NULL }
70
71#define QSLIST_ENTRY(type) \
72struct { \
73 struct type *sle_next; \
74}
75
76
77
78
79#define QSIMPLEQ_HEAD(name, type) \
80struct name { \
81 struct type *sqh_first; \
82 struct type **sqh_last; \
83}
84
85#define QSIMPLEQ_HEAD_INITIALIZER(head) \
86 { NULL, &(head).sqh_first }
87
88#define QSIMPLEQ_ENTRY(type) \
89struct { \
90 struct type *sqe_next; \
91}
92
93
94
95
96#define Q_TAILQ_HEAD(name, type, qual) \
97struct name { \
98 qual type *tqh_first; \
99 qual type *qual *tqh_last; \
100}
101#define QTAILQ_HEAD(name, type) \
102struct name { \
103 type *tqh_first; \
104 type **tqh_last; \
105}
106
107#define QTAILQ_HEAD_INITIALIZER(head) \
108 { NULL, &(head).tqh_first }
109
110#define Q_TAILQ_ENTRY(type, qual) \
111struct { \
112 qual type *tqe_next; \
113 qual type *qual *tqe_prev; \
114}
115#define QTAILQ_ENTRY(type) \
116struct { \
117 type *tqe_next; \
118 type **tqe_prev; \
119}
120
121
122#define g_assert_cmpint(a, op, b) g_assert(a op b)
123#define g_assert_cmpuint(a, op, b) g_assert(a op b)
124#define g_assert_cmphex(a, op, b) g_assert(a op b)
125#define g_assert_cmpstr(a, op, b) g_assert(strcmp(a, b) op 0)
126