[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/27] qemu/atomic: Use macros for CONFIG_ATOMIC64
From: |
Richard Henderson |
Subject: |
[PULL 01/27] qemu/atomic: Use macros for CONFIG_ATOMIC64 |
Date: |
Wed, 21 Jul 2021 09:59:28 -1000 |
Clang warnings about questionable atomic usage get localized
to the inline function in atomic.h. By using a macro, we get
the full traceback to the original use that caused the warning.
Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/atomic.h | 29 +++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)
diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index 3ccf84fd46..a7654d2a33 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -457,26 +457,15 @@
/* Abstractions to access atomically (i.e. "once") i64/u64 variables */
#ifdef CONFIG_ATOMIC64
-static inline int64_t qatomic_read_i64(const int64_t *ptr)
-{
- /* use __nocheck because sizeof(void *) might be < sizeof(u64) */
- return qatomic_read__nocheck(ptr);
-}
-
-static inline uint64_t qatomic_read_u64(const uint64_t *ptr)
-{
- return qatomic_read__nocheck(ptr);
-}
-
-static inline void qatomic_set_i64(int64_t *ptr, int64_t val)
-{
- qatomic_set__nocheck(ptr, val);
-}
-
-static inline void qatomic_set_u64(uint64_t *ptr, uint64_t val)
-{
- qatomic_set__nocheck(ptr, val);
-}
+/* Use __nocheck because sizeof(void *) might be < sizeof(u64) */
+#define qatomic_read_i64(P) \
+ _Generic(*(P), int64_t: qatomic_read__nocheck(P))
+#define qatomic_read_u64(P) \
+ _Generic(*(P), uint64_t: qatomic_read__nocheck(P))
+#define qatomic_set_i64(P, V) \
+ _Generic(*(P), int64_t: qatomic_set__nocheck(P, V))
+#define qatomic_set_u64(P, V) \
+ _Generic(*(P), uint64_t: qatomic_set__nocheck(P, V))
static inline void qatomic64_init(void)
{
--
2.25.1
- [PULL 00/27] tcg patch queue for rc0, Richard Henderson, 2021/07/21
- [PULL 02/27] qemu/atomic: Remove pre-C11 atomic fallbacks, Richard Henderson, 2021/07/21
- [PULL 01/27] qemu/atomic: Use macros for CONFIG_ATOMIC64,
Richard Henderson <=
- [PULL 03/27] qemu/atomic: Add aligned_{int64,uint64}_t types, Richard Henderson, 2021/07/21
- [PULL 04/27] tcg: Rename helper_atomic_*_mmu and provide for user-only, Richard Henderson, 2021/07/21
- [PULL 05/27] accel/tcg: Standardize atomic helpers on softmmu api, Richard Henderson, 2021/07/21
- [PULL 06/27] accel/tcg: Fold EXTRA_ARGS into atomic_template.h, Richard Henderson, 2021/07/21
- [PULL 07/27] accel/tcg: Remove ATOMIC_MMU_DECLS, Richard Henderson, 2021/07/21
- [PULL 08/27] accel/tcg: Expand ATOMIC_MMU_LOOKUP_*, Richard Henderson, 2021/07/21
- [PULL 09/27] trace: Fold mem-internal.h into mem.h, Richard Henderson, 2021/07/21
- [PULL 10/27] accel/tcg: Push trace info building into atomic_common.c.inc, Richard Henderson, 2021/07/21
- [PULL 11/27] accel/tcg: Reduce CF_COUNT_MASK to match TCG_MAX_INSNS, Richard Henderson, 2021/07/21
- [PULL 12/27] accel/tcg: Move curr_cflags into cpu-exec.c, Richard Henderson, 2021/07/21