s390x/virtio-ccw: support virtio-1 set_vq format
[qemu.git] / include / qemu / compiler.h
blobdf9dd514f103ff650c912082c9b6c69d6f39740d
1 /* public domain */
3 #ifndef COMPILER_H
4 #define COMPILER_H
6 #include "config-host.h"
8 /*----------------------------------------------------------------------------
9 | The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler.
10 | The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h.
11 *----------------------------------------------------------------------------*/
12 #if defined(__GNUC__) && defined(__GNUC_MINOR__)
13 # define QEMU_GNUC_PREREQ(maj, min) \
14 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
15 #else
16 # define QEMU_GNUC_PREREQ(maj, min) 0
17 #endif
19 #define QEMU_NORETURN __attribute__ ((__noreturn__))
21 #if QEMU_GNUC_PREREQ(3, 4)
22 #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
23 #else
24 #define QEMU_WARN_UNUSED_RESULT
25 #endif
27 #if QEMU_GNUC_PREREQ(4, 0)
28 #define QEMU_SENTINEL __attribute__((sentinel))
29 #else
30 #define QEMU_SENTINEL
31 #endif
33 #if QEMU_GNUC_PREREQ(4, 3)
34 #define QEMU_ARTIFICIAL __attribute__((always_inline, artificial))
35 #else
36 #define QEMU_ARTIFICIAL
37 #endif
39 #if defined(_WIN32)
40 # define QEMU_PACKED __attribute__((gcc_struct, packed))
41 #else
42 # define QEMU_PACKED __attribute__((packed))
43 #endif
45 #define cat(x,y) x ## y
46 #define cat2(x,y) cat(x,y)
47 #define QEMU_BUILD_BUG_ON(x) \
48 typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1] __attribute__((unused));
50 #if defined __GNUC__
51 # if !QEMU_GNUC_PREREQ(4, 4)
52 /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
53 # define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
54 # else
55 /* Use gnu_printf when supported (qemu uses standard format strings). */
56 # define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
57 # if defined(_WIN32)
58 /* Map __printf__ to __gnu_printf__ because we want standard format strings
59 * even when MinGW or GLib include files use __printf__. */
60 # define __printf__ __gnu_printf__
61 # endif
62 # endif
63 #else
64 #define GCC_FMT_ATTR(n, m)
65 #endif
67 #endif /* COMPILER_H */