atomic16_xchg(Int128 *ptr, Int128 new)
{
__int128_t *ptr_align = __builtin_assume_aligned(ptr, 16);
- Int128 old = *ptr_align;
+ Int128Alias o, n;
- while (!__atomic_compare_exchange_n(ptr_align, &old, new, true,
+ n.s = new;
+ o.i = *ptr_align;
+ while (!__atomic_compare_exchange_n(ptr_align, &o.i, n.i, true,
__ATOMIC_SEQ_CST, 0)) {
continue;
}
- return old;
+ return o.s;
}
static inline Int128 ATTRIBUTE_ATOMIC128_OPT
atomic16_fetch_and(Int128 *ptr, Int128 val)
{
__int128_t *ptr_align = __builtin_assume_aligned(ptr, 16);
- Int128 old = *ptr_align;
+ Int128Alias o, v;
- while (!__atomic_compare_exchange_n(ptr_align, &old, old & val, true,
+ v.s = val;
+ o.i = *ptr_align;
+ while (!__atomic_compare_exchange_n(ptr_align, &o.i, o.i & v.i, true,
__ATOMIC_SEQ_CST, 0)) {
continue;
}
- return old;
+ return o.s;
}
static inline Int128 ATTRIBUTE_ATOMIC128_OPT
atomic16_fetch_or(Int128 *ptr, Int128 val)
{
__int128_t *ptr_align = __builtin_assume_aligned(ptr, 16);
- Int128 old = *ptr_align;
+ Int128Alias o, v;
- while (!__atomic_compare_exchange_n(ptr_align, &old, old | val, true,
+ v.s = val;
+ o.i = *ptr_align;
+ while (!__atomic_compare_exchange_n(ptr_align, &o.i, o.i | v.i, true,
__ATOMIC_SEQ_CST, 0)) {
continue;
}
- return old;
+ return o.s;
}
# define HAVE_CMPXCHG128 1
#elif defined(CONFIG_CMPXCHG128)