linux-user: Handle TARGET_MAP_STACK and TARGET_MAP_HUGETLB
[qemu/ar7.git] / scripts / cocci-macro-file.h
blob9f2e72e7e15ac7c776c804d8262a71fd0138a2e6
1 /* Macro file for Coccinelle
3 * Copyright (C) 2015 Red Hat, Inc.
5 * Authors:
6 * Paolo Bonzini <pbonzini@redhat.com>
8 * This work is licensed under the terms of the GNU GPL, version 2 or, at your
9 * option, any later version. See the COPYING file in the top-level directory.
12 /* Coccinelle only does limited parsing of headers, and chokes on some idioms
13 * defined in compiler.h and queue.h. Macros that Coccinelle must know about
14 * in order to parse .c files must be in a separate macro file---which is
15 * exactly what you're staring at now.
17 * To use this file, add the "--macro-file scripts/cocci-macro-file.h" to the
18 * Coccinelle command line.
21 /* From qemu/compiler.h */
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))
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));
34 #define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
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
41 #define typeof_field(type, field) typeof(((type *)0)->field)
42 #define type_check(t1,t2) ((t1*)0 - (t2*)0)
44 /* From qemu/queue.h */
46 #define QLIST_HEAD(name, type) \
47 struct name { \
48 struct type *lh_first; /* first element */ \
51 #define QLIST_HEAD_INITIALIZER(head) \
52 { NULL }
54 #define QLIST_ENTRY(type) \
55 struct { \
56 struct type *le_next; /* next element */ \
57 struct type **le_prev; /* address of previous next element */ \
61 * Singly-linked List definitions.
63 #define QSLIST_HEAD(name, type) \
64 struct name { \
65 struct type *slh_first; /* first element */ \
68 #define QSLIST_HEAD_INITIALIZER(head) \
69 { NULL }
71 #define QSLIST_ENTRY(type) \
72 struct { \
73 struct type *sle_next; /* next element */ \
77 * Simple queue definitions.
79 #define QSIMPLEQ_HEAD(name, type) \
80 struct name { \
81 struct type *sqh_first; /* first element */ \
82 struct type **sqh_last; /* addr of last next element */ \
85 #define QSIMPLEQ_HEAD_INITIALIZER(head) \
86 { NULL, &(head).sqh_first }
88 #define QSIMPLEQ_ENTRY(type) \
89 struct { \
90 struct type *sqe_next; /* next element */ \
94 * Tail queue definitions.
96 #define Q_TAILQ_HEAD(name, type, qual) \
97 struct name { \
98 qual type *tqh_first; /* first element */ \
99 qual type *qual *tqh_last; /* addr of last next element */ \
101 #define QTAILQ_HEAD(name, type) \
102 struct name { \
103 type *tqh_first; /* first element */ \
104 type **tqh_last; /* addr of last next element */ \
107 #define QTAILQ_HEAD_INITIALIZER(head) \
108 { NULL, &(head).tqh_first }
110 #define Q_TAILQ_ENTRY(type, qual) \
111 struct { \
112 qual type *tqe_next; /* next element */ \
113 qual type *qual *tqe_prev; /* address of previous next element */\
115 #define QTAILQ_ENTRY(type) \
116 struct { \
117 type *tqe_next; /* next element */ \
118 type **tqe_prev; /* address of previous next element */ \
121 /* From glib */
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)