On Mon, Jun 24, 2024 at 08:56:47PM +0000, Felix Wu wrote:
> From: Roman Kiryanov <r...@google.com>
> 
> to use the QEMU headers with a C++ compiler.
> 
> Signed-off-by: Felix Wu <f...@google.com>
> Signed-off-by: Roman Kiryanov <r...@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 :|


Reply via email to