[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/47] include/qemu/thread: Use qatomic_* functions
From: |
Richard Henderson |
Subject: |
[PULL 07/47] include/qemu/thread: Use qatomic_* functions |
Date: |
Wed, 26 Oct 2022 12:10:36 +1000 |
Use qatomic_*, which expands to __atomic_* in preference
to the "legacy" __sync_* functions.
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/thread.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/qemu/thread.h b/include/qemu/thread.h
index af19f2b3fc..20641e5844 100644
--- a/include/qemu/thread.h
+++ b/include/qemu/thread.h
@@ -227,7 +227,7 @@ struct QemuSpin {
static inline void qemu_spin_init(QemuSpin *spin)
{
- __sync_lock_release(&spin->value);
+ qatomic_set(&spin->value, 0);
#ifdef CONFIG_TSAN
__tsan_mutex_create(spin, __tsan_mutex_not_static);
#endif
@@ -246,7 +246,7 @@ static inline void qemu_spin_lock(QemuSpin *spin)
#ifdef CONFIG_TSAN
__tsan_mutex_pre_lock(spin, 0);
#endif
- while (unlikely(__sync_lock_test_and_set(&spin->value, true))) {
+ while (unlikely(qatomic_xchg(&spin->value, 1))) {
while (qatomic_read(&spin->value)) {
cpu_relax();
}
@@ -261,7 +261,7 @@ static inline bool qemu_spin_trylock(QemuSpin *spin)
#ifdef CONFIG_TSAN
__tsan_mutex_pre_lock(spin, __tsan_mutex_try_lock);
#endif
- bool busy = __sync_lock_test_and_set(&spin->value, true);
+ bool busy = qatomic_xchg(&spin->value, true);
#ifdef CONFIG_TSAN
unsigned flags = __tsan_mutex_try_lock;
flags |= busy ? __tsan_mutex_try_lock_failed : 0;
@@ -280,7 +280,7 @@ static inline void qemu_spin_unlock(QemuSpin *spin)
#ifdef CONFIG_TSAN
__tsan_mutex_pre_unlock(spin, 0);
#endif
- __sync_lock_release(&spin->value);
+ qatomic_store_release(&spin->value, 0);
#ifdef CONFIG_TSAN
__tsan_mutex_post_unlock(spin, 0);
#endif
--
2.34.1
- [PULL 00/47] tcg patch queue, Richard Henderson, 2022/10/25
- [PULL 01/47] Revert "accel/tcg: Init TCG cflags in vCPU thread handler", Richard Henderson, 2022/10/25
- [PULL 02/47] tcg/loongarch64: Add direct jump support, Richard Henderson, 2022/10/25
- [PULL 03/47] tcg/aarch64: Remove unused code in tcg_out_op, Richard Henderson, 2022/10/25
- [PULL 05/47] include/qemu/osdep: Add qemu_build_assert, Richard Henderson, 2022/10/25
- [PULL 04/47] accel/tcg: Add a quicker check for breakpoints, Richard Henderson, 2022/10/25
- [PULL 06/47] include/qemu/atomic: Use qemu_build_assert, Richard Henderson, 2022/10/25
- [PULL 08/47] accel/tcg: Make page_alloc_target_data allocation constant, Richard Henderson, 2022/10/25
- [PULL 07/47] include/qemu/thread: Use qatomic_* functions,
Richard Henderson <=
- [PULL 09/47] accel/tcg: Remove disabled debug in translate-all.c, Richard Henderson, 2022/10/25
- [PULL 10/47] accel/tcg: Split out PageDesc to internal.h, Richard Henderson, 2022/10/25
- [PULL 12/47] accel/tcg: Move assert_no_pages_locked to internal.h, Richard Henderson, 2022/10/25
- [PULL 11/47] accel/tcg: Split out tb-maint.c, Richard Henderson, 2022/10/25
- [PULL 13/47] accel/tcg: Drop cpu_get_tb_cpu_state from TARGET_HAS_PRECISE_SMC, Richard Henderson, 2022/10/25
- [PULL 14/47] accel/tcg: Remove duplicate store to tb->page_addr[], Richard Henderson, 2022/10/25
- [PULL 15/47] accel/tcg: Introduce tb_{set_}page_addr{0,1}, Richard Henderson, 2022/10/25
- [PULL 16/47] accel/tcg: Rename tb_invalidate_phys_page, Richard Henderson, 2022/10/25
- [PULL 17/47] accel/tcg: Rename tb_invalidate_phys_page_range and drop end parameter, Richard Henderson, 2022/10/25
- [PULL 18/47] accel/tcg: Unify declarations of tb_invalidate_phys_range, Richard Henderson, 2022/10/25