qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH experiment 05/16] port atomic.h to C++


From: Paolo Bonzini
Subject: [PATCH experiment 05/16] port atomic.h to C++
Date: Mon, 14 Mar 2022 10:31:52 +0100

The functionality of typeof_strip_qual is provided by the standard library.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/atomic.h | 5 +++++
 include/qemu/osdep.h  | 1 +
 2 files changed, 6 insertions(+)

diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index 112a29910b..0889a9c5d2 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -26,6 +26,10 @@
  * implicit promotion.  int and larger types, as well as pointers, can be
  * converted to a non-qualified type just by applying a binary operator.
  */
+#ifdef __cplusplus
+#define typeof_strip_qual(expr)                                                
    \
+       std::remove_cv<typeof(expr)>::type
+#else
 #define typeof_strip_qual(expr)                                                
    \
   typeof(                                                                      
    \
     __builtin_choose_expr(                                                     
    \
@@ -59,6 +63,7 @@
         __builtin_types_compatible_p(typeof(expr), const volatile unsigned 
short), \
         (unsigned short)1,                                                     
    \
       (expr)+0))))))
+#endif
 
 #ifndef __ATOMIC_RELAXED
 #error "Expecting C11 atomic ops"
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index c9ec7830c9..28707bbde3 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -140,6 +140,7 @@ QEMU_EXTERN_C int daemon(int, int);
 #endif
 
 #ifdef __cplusplus
+#include <type_traits>
 extern "C" {
 #endif
 
-- 
2.35.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]