qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Felix Wu <flwu@google.com>
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org,
	Roman Kiryanov <rkir@google.com>
Subject: Re: [PATCH 1/1] include/qemu: Provide a C++ compatible version of typeof_strip_qual
Date: Tue, 25 Jun 2024 08:52:33 +0100	[thread overview]
Message-ID: <Znp3QTTrlHDhwRA_@redhat.com> (raw)
In-Reply-To: <20240624205647.112034-1-flwu@google.com>

On Mon, Jun 24, 2024 at 08:56:47PM +0000, Felix Wu wrote:
> From: Roman Kiryanov <rkir@google.com>
> 
> to use the QEMU headers with a C++ compiler.
> 
> Signed-off-by: Felix Wu <flwu@google.com>
> Signed-off-by: Roman Kiryanov <rkir@google.com>
> ---
>  include/qemu/atomic.h   |  8 ++++++++
>  include/qemu/atomic.hpp | 38 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 46 insertions(+)
>  create mode 100644 include/qemu/atomic.hpp
> 
> diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
> index 99110abefb..aeaecc440a 100644
> --- a/include/qemu/atomic.h
> +++ b/include/qemu/atomic.h
> @@ -20,6 +20,13 @@
>  /* Compiler barrier */
>  #define barrier()   ({ asm volatile("" ::: "memory"); (void)0; })
>  
> +#ifdef __cplusplus
> +
> +#ifndef typeof_strip_qual
> +#error Use the typeof_strip_qual(expr) definition from atomic.hpp on C++ builds.
> +#endif
> +
> +#else  /* __cpluplus */
>  /* The variable that receives the old value of an atomically-accessed
>   * variable must be non-qualified, because atomic builtins return values
>   * through a pointer-type argument as in __atomic_load(&var, &old, MODEL).
> @@ -61,6 +68,7 @@
>          __builtin_types_compatible_p(typeof(expr), const volatile unsigned short), \
>          (unsigned short)1,                                                         \
>        (expr)+0))))))
> +#endif  /* __cpluplus */
>  
>  #ifndef __ATOMIC_RELAXED
>  #error "Expecting C11 atomic ops"
> diff --git a/include/qemu/atomic.hpp b/include/qemu/atomic.hpp
> new file mode 100644
> index 0000000000..5844e3d427
> --- /dev/null
> +++ b/include/qemu/atomic.hpp

snip

IMHO we don't want to see this code in QEMU - we are a C project, not a
C++ project.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



      parent reply	other threads:[~2024-06-25  7:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-24 20:56 [PATCH 1/1] include/qemu: Provide a C++ compatible version of typeof_strip_qual Felix Wu
2024-06-25  2:26 ` Philippe Mathieu-Daudé
2024-06-25  2:32   ` Roman Kiryanov
2024-06-25  6:05     ` Paolo Bonzini
2024-06-25  6:19       ` Philippe Mathieu-Daudé
2024-06-25  9:27         ` Peter Maydell
2024-06-25 10:16           ` Peter Maydell
2024-06-25 10:31             ` Daniel P. Berrangé
2024-06-25  6:07     ` Thomas Huth
2024-06-25  7:52 ` Daniel P. Berrangé [this message]

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=Znp3QTTrlHDhwRA_@redhat.com \
    --to=berrange@redhat.com \
    --cc=flwu@google.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rkir@google.com \
    /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).