From 230f6e06b83474314898f27c0a7b2f0593071875 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 5 Oct 2023 14:31:27 +0200 Subject: 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 --- include/qemu/compiler.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/qemu/compiler.h') diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 1109482a00..c797f0d457 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 */ -- cgit 1.4.1