aboutsummaryrefslogtreecommitdiff
path: root/host/include/generic
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2023-05-19 20:53:16 -0700
committerRichard Henderson <richard.henderson@linaro.org>2023-05-23 18:54:55 -0700
commitb35b812567f090e41c4b194bb2a752f29e9aedcc (patch)
tree4bd808b56cc05271055c995753c366f0ba1b1fd8 /host/include/generic
parent427fbf3721da334c1f429d2a5285caa7025139c2 (diff)
downloadqemu-b35b812567f090e41c4b194bb2a752f29e9aedcc.zip
qemu-b35b812567f090e41c4b194bb2a752f29e9aedcc.tar.gz
qemu-b35b812567f090e41c4b194bb2a752f29e9aedcc.tar.bz2
qemu/atomic128: Improve cmpxchg fallback for atomic16_set
Use __sync_bool_compare_and_swap_16 to control the loop, rather than a separate comparison. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'host/include/generic')
-rw-r--r--host/include/generic/host/atomic128-ldst.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/host/include/generic/host/atomic128-ldst.h b/host/include/generic/host/atomic128-ldst.h
index 79d208b..80fff06 100644
--- a/host/include/generic/host/atomic128-ldst.h
+++ b/host/include/generic/host/atomic128-ldst.h
@@ -58,11 +58,14 @@ atomic16_read_rw(Int128 *ptr)
static inline void ATTRIBUTE_ATOMIC128_OPT
atomic16_set(Int128 *ptr, Int128 val)
{
- Int128 old = *ptr, cmp;
+ __int128_t *ptr_align = __builtin_assume_aligned(ptr, 16);
+ __int128_t old;
+ Int128Alias new;
+
+ new.s = val;
do {
- cmp = old;
- old = atomic16_cmpxchg(ptr, cmp, val);
- } while (int128_ne(old, cmp));
+ old = *ptr_align;
+ } while (!__sync_bool_compare_and_swap_16(ptr_align, old, new.i));
}
#else