mirror of https://github.com/xemu-project/xemu.git
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>
This commit is contained in:
parent
427fbf3721
commit
b35b812567
|
@ -58,11 +58,14 @@ atomic16_read_rw(Int128 *ptr)
|
||||||
static inline void ATTRIBUTE_ATOMIC128_OPT
|
static inline void ATTRIBUTE_ATOMIC128_OPT
|
||||||
atomic16_set(Int128 *ptr, Int128 val)
|
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 {
|
do {
|
||||||
cmp = old;
|
old = *ptr_align;
|
||||||
old = atomic16_cmpxchg(ptr, cmp, val);
|
} while (!__sync_bool_compare_and_swap_16(ptr_align, old, new.i));
|
||||||
} while (int128_ne(old, cmp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue