aboutsummaryrefslogtreecommitdiff
path: root/include/qemu/compiler.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2023-10-05 14:31:27 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2023-10-17 15:20:53 +0200
commit230f6e06b83474314898f27c0a7b2f0593071875 (patch)
treee284eff89e498a4a22c95ab40a0b1c48173bef0b /include/qemu/compiler.h
parent9bad39c7e86a7fea05b66e7d3425f5874b3bbcfb (diff)
downloadqemu-230f6e06b83474314898f27c0a7b2f0593071875.zip
qemu-230f6e06b83474314898f27c0a7b2f0593071875.tar.gz
qemu-230f6e06b83474314898f27c0a7b2f0593071875.tar.bz2
meson: do not use set10
Make all items of config-host.h consistent. To keep the --disable-coroutine-pool code visible to the compiler, mutuate the IS_ENABLED() macro from Linux. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/qemu/compiler.h')
-rw-r--r--include/qemu/compiler.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 1109482..c797f0d 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -212,4 +212,19 @@
# define QEMU_USED
#endif
+/*
+ * Ugly CPP trick that is like "defined FOO", but also works in C
+ * code. Useful to replace #ifdef with "if" statements; assumes
+ * the symbol was defined with Meson's "config.set()", so it is empty
+ * if defined.
+ */
+#define IS_ENABLED(x) IS_EMPTY(x)
+
+#define IS_EMPTY_JUNK_ junk,
+#define IS_EMPTY(value) IS_EMPTY_(IS_EMPTY_JUNK_##value)
+
+/* Expands to either SECOND_ARG(junk, 1, 0) or SECOND_ARG(IS_EMPTY_JUNK_CONFIG_FOO 1, 0) */
+#define SECOND_ARG(first, second, ...) second
+#define IS_EMPTY_(junk_maybecomma) SECOND_ARG(junk_maybecomma 1, 0)
+
#endif /* COMPILER_H */