root / compiler.h @ 73f5e313
History | View | Annotate | Download (1.6 kB)
1 | 5c026320 | Luiz Capitulino | /* public domain */
|
---|---|---|---|
2 | 5c026320 | Luiz Capitulino | |
3 | 5c026320 | Luiz Capitulino | #ifndef COMPILER_H
|
4 | 5c026320 | Luiz Capitulino | #define COMPILER_H
|
5 | 5c026320 | Luiz Capitulino | |
6 | 5c026320 | Luiz Capitulino | #include "config-host.h" |
7 | 5c026320 | Luiz Capitulino | |
8 | f8b72754 | Stefan Weil | /*----------------------------------------------------------------------------
|
9 | f8b72754 | Stefan Weil | | The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler.
|
10 | f8b72754 | Stefan Weil | | The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h.
|
11 | f8b72754 | Stefan Weil | *----------------------------------------------------------------------------*/
|
12 | f8b72754 | Stefan Weil | #if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
13 | f8b72754 | Stefan Weil | # define QEMU_GNUC_PREREQ(maj, min) \
|
14 | f8b72754 | Stefan Weil | ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) |
15 | f8b72754 | Stefan Weil | #else
|
16 | f8b72754 | Stefan Weil | # define QEMU_GNUC_PREREQ(maj, min) 0 |
17 | f8b72754 | Stefan Weil | #endif
|
18 | f8b72754 | Stefan Weil | |
19 | 5c026320 | Luiz Capitulino | #define QEMU_NORETURN __attribute__ ((__noreturn__))
|
20 | f8b72754 | Stefan Weil | |
21 | 87751797 | Stefan Weil | #if QEMU_GNUC_PREREQ(3, 4) |
22 | 5c026320 | Luiz Capitulino | #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
23 | 5c026320 | Luiz Capitulino | #else
|
24 | 5c026320 | Luiz Capitulino | #define QEMU_WARN_UNUSED_RESULT
|
25 | 5c026320 | Luiz Capitulino | #endif
|
26 | 5c026320 | Luiz Capitulino | |
27 | 0f7fdd34 | Stefan Weil | #if defined(_WIN32)
|
28 | 0f7fdd34 | Stefan Weil | # define QEMU_PACKED __attribute__((gcc_struct, packed))
|
29 | 0f7fdd34 | Stefan Weil | #else
|
30 | 0f7fdd34 | Stefan Weil | # define QEMU_PACKED __attribute__((packed))
|
31 | 0f7fdd34 | Stefan Weil | #endif
|
32 | 0f7fdd34 | Stefan Weil | |
33 | 5c026320 | Luiz Capitulino | #define QEMU_BUILD_BUG_ON(x) \
|
34 | 5c026320 | Luiz Capitulino | typedef char qemu_build_bug_on__##__LINE__[(x)?-1:1]; |
35 | 5c026320 | Luiz Capitulino | |
36 | 5c026320 | Luiz Capitulino | #if defined __GNUC__
|
37 | f8b72754 | Stefan Weil | # if !QEMU_GNUC_PREREQ(4, 4) |
38 | 5c026320 | Luiz Capitulino | /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
|
39 | 5c026320 | Luiz Capitulino | # define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2))) |
40 | 5c026320 | Luiz Capitulino | # define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
|
41 | 5c026320 | Luiz Capitulino | # else
|
42 | 5c026320 | Luiz Capitulino | /* Use gnu_printf when supported (qemu uses standard format strings). */
|
43 | 5c026320 | Luiz Capitulino | # define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2))) |
44 | 5c026320 | Luiz Capitulino | # define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
|
45 | 5c026320 | Luiz Capitulino | # endif
|
46 | 5c026320 | Luiz Capitulino | #else
|
47 | 5c026320 | Luiz Capitulino | #define GCC_ATTR /**/ |
48 | 5c026320 | Luiz Capitulino | #define GCC_FMT_ATTR(n, m)
|
49 | 5c026320 | Luiz Capitulino | #endif
|
50 | 5c026320 | Luiz Capitulino | |
51 | 5c026320 | Luiz Capitulino | #endif /* COMPILER_H */ |