[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
- [PATCH experiment 00/16] C++20 coroutine backend, Paolo Bonzini, 2022/03/14
- [PATCH experiment 01/16] coroutine: add missing coroutine_fn annotations for CoRwlock functions, Paolo Bonzini, 2022/03/14
- [PATCH experiment 06/16] use g_new0 instead of g_malloc0, Paolo Bonzini, 2022/03/14
- [PATCH experiment 02/16] coroutine: qemu_coroutine_get_aio_context is not a coroutine_fn, Paolo Bonzini, 2022/03/14
- [PATCH experiment 08/16] tracetool: add extern "C" around generated headers, Paolo Bonzini, 2022/03/14
- [PATCH experiment 03/16] coroutine: small code cleanup in qemu_co_rwlock_wrlock, Paolo Bonzini, 2022/03/14
- [PATCH experiment 05/16] port atomic.h to C++,
Paolo Bonzini <=
- [PATCH experiment 04/16] coroutine: introduce QemuCoLockable, Paolo Bonzini, 2022/03/14
- [PATCH experiment 07/16] start porting compiler.h to C++, Paolo Bonzini, 2022/03/14
- [PATCH experiment 11/16] bump to C++20, Paolo Bonzini, 2022/03/14
- [PATCH experiment 12/16] remove "new" keyword from trace-events, Paolo Bonzini, 2022/03/14
- [PATCH experiment 09/16] start adding extern "C" markers, Paolo Bonzini, 2022/03/14
- [PATCH experiment 10/16] add space between liter and string macro, Paolo Bonzini, 2022/03/14
- [PATCH experiment 13/16] disable some code, Paolo Bonzini, 2022/03/14
- [PATCH experiment 16/16] port test-coroutine to C++ coroutines, Paolo Bonzini, 2022/03/14
- [PATCH experiment 14/16] util: introduce C++ stackless coroutine backend, Paolo Bonzini, 2022/03/14