]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
include/generic/host: Fix atomic128-cas.h.inc for Int128 structure
authorRichard Henderson <richard.henderson@linaro.org>
Wed, 3 Dec 2025 13:41:45 +0000 (13:41 +0000)
committerRichard Henderson <richard.henderson@linaro.org>
Fri, 5 Dec 2025 13:50:15 +0000 (07:50 -0600)
Use the Int128Alias structure more when we need to convert
between Int128 and __int128_t, when Int128 is a struct.

Fixes the build on aarch64 host with TCI, which forces
the use of the struct.

Reported-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
host/include/generic/host/atomic128-cas.h.inc

index 990162c56fe2b1cfa2b392d16ac383a169e1b19c..8bf5f47768db2b3229dfba2d2a60e1b8cf58481b 100644 (file)
@@ -34,39 +34,45 @@ static inline Int128 ATTRIBUTE_ATOMIC128_OPT
 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)