qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH 02/17] meson: do not use set10
Date: Wed, 18 Oct 2023 17:06:43 -0700	[thread overview]
Message-ID: <2ebff1c7-e820-40db-ae5b-6cb8e6e4f359@linaro.org> (raw)
In-Reply-To: <20231016063127.161204-3-pbonzini@redhat.com>

On 10/15/23 23:31, Paolo Bonzini wrote:
> 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>
> ---
>   include/qemu/compiler.h     | 15 +++++++++++++++
>   meson.build                 |  2 +-
>   tests/unit/test-coroutine.c |  2 +-
>   util/qemu-coroutine.c       |  4 ++--
>   4 files changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
> index 1109482a000..c797f0d4572 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)

Clever that.

However, if I had a preference I would go the other way and model after glibc:

Convert everything away from ifdef and always use set01.
Then enable -Wundef so that you catch typos in the usage of these macros.

But this is an improvement of a sort so,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~



  reply	other threads:[~2023-10-19  0:07 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-16  6:31 [PATCH 00/17] More build system cleanups, optional non-relocatable installs Paolo Bonzini
2023-10-16  6:31 ` [PATCH 01/17] meson: do not build shaders by default Paolo Bonzini
2023-10-16  9:04   ` Manos Pitsidianakis
2023-10-16  6:31 ` [PATCH 02/17] meson: do not use set10 Paolo Bonzini
2023-10-19  0:06   ` Richard Henderson [this message]
2023-10-16  6:31 ` [PATCH 03/17] meson, cutils: allow non-relocatable installs Paolo Bonzini
2023-10-16  7:12   ` Markus Armbruster
2023-10-16 21:29     ` Paolo Bonzini
2023-10-17  5:46       ` Markus Armbruster
2023-10-16  9:08   ` Manos Pitsidianakis
2023-10-16  9:48     ` Paolo Bonzini
2023-10-16  6:31 ` [PATCH 04/17] configure: clean up handling of CFI option Paolo Bonzini
2023-10-16  9:22   ` Philippe Mathieu-Daudé
2023-10-16  9:44     ` Paolo Bonzini
2023-10-16 13:33       ` Philippe Mathieu-Daudé
2023-10-16  6:31 ` [PATCH 05/17] hw/xen: cleanup sourcesets Paolo Bonzini
2023-10-16  6:31 ` [PATCH 06/17] hw/remote: move stub vfu_object_set_bus_irq out of stubs/ Paolo Bonzini
2023-10-16  6:31 ` [PATCH 07/17] tests/tcg/arm: move non-SVE tests out of conditional Paolo Bonzini
2023-10-16  6:31 ` [PATCH 08/17] configure, tests/tcg: simplify GDB conditionals Paolo Bonzini
2023-10-16  9:12   ` Manos Pitsidianakis
2023-10-16  6:31 ` [PATCH 09/17] configure: clean up plugin option handling Paolo Bonzini
2023-10-16  6:31 ` [PATCH 10/17] configure: clean up PIE " Paolo Bonzini
2023-10-16  6:31 ` [PATCH 11/17] configure: remove some dead cruft Paolo Bonzini
2023-10-16  9:32   ` Thomas Huth
2023-10-16  6:31 ` [PATCH 12/17] configure: move target-specific defaults to an external machine file Paolo Bonzini
2023-10-16  6:31 ` [PATCH 13/17] configure: move environment-specific defaults to config-meson.cross Paolo Bonzini
2023-10-16  6:31 ` [PATCH 14/17] configure: unify handling of several Debian cross containers Paolo Bonzini
2023-10-16  6:31 ` [PATCH 15/17] configure, meson: use command line options to configure qemu-ga Paolo Bonzini
2023-10-16  6:31 ` [PATCH 16/17] meson-buildoptions: document the data at the top Paolo Bonzini
2023-10-16  6:31 ` [PATCH 17/17] meson: add a note on why we use config_host for program paths Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2ebff1c7-e820-40db-ae5b-6cb8e6e4f359@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).