[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 02/11] qemu/atomic: Simplify typeof_strip_qual
From: |
Richard Henderson |
Subject: |
[PATCH v2 02/11] qemu/atomic: Simplify typeof_strip_qual |
Date: |
Fri, 16 Jul 2021 18:41:12 -0700 |
The right-hand side of the comma operator has the type quals
stripped without also undergoing implicit promotion.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/atomic.h | 41 ++++-------------------------------------
1 file changed, 4 insertions(+), 37 deletions(-)
diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index 99d6030095..55d75fc757 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -18,47 +18,14 @@
/* Compiler barrier */
#define barrier() ({ asm volatile("" ::: "memory"); (void)0; })
-/* The variable that receives the old value of an atomically-accessed
+/*
+ * 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).
*
- * This macro has to handle types smaller than int manually, because of
- * implicit promotion. int and larger types, as well as pointers, can be
- * converted to a non-qualified type just by applying a binary operator.
+ * Handle this by evaluating an expression involving the comma operator.
*/
-#define typeof_strip_qual(expr)
\
- typeof(
\
- __builtin_choose_expr(
\
- __builtin_types_compatible_p(typeof(expr), bool) ||
\
- __builtin_types_compatible_p(typeof(expr), const bool) ||
\
- __builtin_types_compatible_p(typeof(expr), volatile bool) ||
\
- __builtin_types_compatible_p(typeof(expr), const volatile bool),
\
- (bool)1,
\
- __builtin_choose_expr(
\
- __builtin_types_compatible_p(typeof(expr), signed char) ||
\
- __builtin_types_compatible_p(typeof(expr), const signed char) ||
\
- __builtin_types_compatible_p(typeof(expr), volatile signed char) ||
\
- __builtin_types_compatible_p(typeof(expr), const volatile signed
char), \
- (signed char)1,
\
- __builtin_choose_expr(
\
- __builtin_types_compatible_p(typeof(expr), unsigned char) ||
\
- __builtin_types_compatible_p(typeof(expr), const unsigned char) ||
\
- __builtin_types_compatible_p(typeof(expr), volatile unsigned char) ||
\
- __builtin_types_compatible_p(typeof(expr), const volatile unsigned
char), \
- (unsigned char)1,
\
- __builtin_choose_expr(
\
- __builtin_types_compatible_p(typeof(expr), signed short) ||
\
- __builtin_types_compatible_p(typeof(expr), const signed short) ||
\
- __builtin_types_compatible_p(typeof(expr), volatile signed short) ||
\
- __builtin_types_compatible_p(typeof(expr), const volatile signed
short), \
- (signed short)1,
\
- __builtin_choose_expr(
\
- __builtin_types_compatible_p(typeof(expr), unsigned short) ||
\
- __builtin_types_compatible_p(typeof(expr), const unsigned short) ||
\
- __builtin_types_compatible_p(typeof(expr), volatile unsigned short) ||
\
- __builtin_types_compatible_p(typeof(expr), const volatile unsigned
short), \
- (unsigned short)1,
\
- (expr)+0))))))
+#define typeof_strip_qual(expr) typeof((void)0, (expr))
#ifdef __ATOMIC_RELAXED
/* For C11 atomic ops */
--
2.25.1
- [PATCH v2 00/11] Atomic cleanup + clang-12 build fix, Richard Henderson, 2021/07/16
- [PATCH v2 01/11] qemu/atomic: Use macros for CONFIG_ATOMIC64, Richard Henderson, 2021/07/16
- [PATCH v2 02/11] qemu/atomic: Simplify typeof_strip_qual,
Richard Henderson <=
- [PATCH v2 03/11] qemu/atomic: Remove pre-C11 atomic fallbacks, Richard Henderson, 2021/07/16
- [PATCH v2 05/11] tcg: Rename helper_atomic_*_mmu and provide for user-only, Richard Henderson, 2021/07/16
- [PATCH v2 07/11] accel/tcg: Fold EXTRA_ARGS into atomic_template.h, Richard Henderson, 2021/07/16
- [PATCH v2 04/11] qemu/atomic: Add aligned_{int64,uint64}_t types, Richard Henderson, 2021/07/16
- [PATCH v2 06/11] accel/tcg: Standardize atomic helpers on softmmu api, Richard Henderson, 2021/07/16
- [PATCH v2 09/11] accel/tcg: Expand ATOMIC_MMU_LOOKUP_*, Richard Henderson, 2021/07/16
- [PATCH v2 10/11] trace: Fold mem-internal.h into mem.h, Richard Henderson, 2021/07/16