sd/milkymist-memcard: Fix format string
[qemu/armbru.git] / scripts / cocci-macro-file.h
blobc6bbc05ba3eada172a1370372eeb4a5c309ee5d9
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))
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
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));
38 #define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
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
45 #define typeof_field(type, field) typeof(((type *)0)->field)
46 #define type_check(t1,t2) ((t1*)0 - (t2*)0)
48 /* From qemu/queue.h */
50 #define QLIST_HEAD(name, type) \
51 struct name { \
52 struct type *lh_first; /* first element */ \
55 #define QLIST_HEAD_INITIALIZER(head) \
56 { NULL }
58 #define QLIST_ENTRY(type) \
59 struct { \
60 struct type *le_next; /* next element */ \
61 struct type **le_prev; /* address of previous next element */ \
65 * Singly-linked List definitions.
67 #define QSLIST_HEAD(name, type) \
68 struct name { \
69 struct type *slh_first; /* first element */ \
72 #define QSLIST_HEAD_INITIALIZER(head) \
73 { NULL }
75 #define QSLIST_ENTRY(type) \
76 struct { \
77 struct type *sle_next; /* next element */ \
81 * Simple queue definitions.
83 #define QSIMPLEQ_HEAD(name, type) \
84 struct name { \
85 struct type *sqh_first; /* first element */ \
86 struct type **sqh_last; /* addr of last next element */ \
89 #define QSIMPLEQ_HEAD_INITIALIZER(head) \
90 { NULL, &(head).sqh_first }
92 #define QSIMPLEQ_ENTRY(type) \
93 struct { \
94 struct type *sqe_next; /* next element */ \
98 * Tail queue definitions.
100 #define QTAILQ_HEAD(name, type) \
101 union name { \
102 struct type *tqh_first; /* first element */ \
103 QTailQLink tqh_circ; /* link for last element */ \
106 #define QTAILQ_HEAD_INITIALIZER(head) \
107 { .tqh_circ = { NULL, &(head).tqh_circ } }
109 #define QTAILQ_ENTRY(type) \
110 union { \
111 struct type *tqe_next; /* next element */ \
112 QTailQLink tqe_circ; /* link for prev element */ \
115 /* From glib */
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)