summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2025-09-08 14:38:22 +0200
committerH.J. Lu <hjl.tools@gmail.com>2025-09-09 07:51:41 -0700
commit935ee691bce7aa8c957714deea4868e5aefb52c9 (patch)
tree5717ee513c5606c1f00d4c1ceb4edd8fa8c3ec30
parente6b5ad1b1d9f8dcb80b711747f3abffec29408e3 (diff)
x86: Define atomic_exchange_acq using __atomic_exchange_n
The resulting libc.so is identical on both x86_64 and i386 targets compared to unpatched builds: $ sha1sum libc-x86_64-old.so libc-x86_64-new.so 74eca1b87f2ecc9757a984c089a582b7615d93e7 libc-x86_64-old.so 74eca1b87f2ecc9757a984c089a582b7615d93e7 libc-x86_64-new.so $ sha1sum libc-i386-old.so libc-i386-new.so 882bbab8324f79f4fbc85224c4c914fc6822ece7 libc-i386-old.so 882bbab8324f79f4fbc85224c4c914fc6822ece7 libc-i386-new.so Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Cc: Florian Weimer <fweimer@redhat.com> Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com> Cc: Collin Funk <collin.funk1@gmail.com> Cc: H.J.Lu <hjl.tools@gmail.com> Cc: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
-rw-r--r--sysdeps/x86/atomic-machine.h29
1 files changed, 1 insertions, 28 deletions
diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h
index c0c2c3437a..ebe8e978e5 100644
--- a/sysdeps/x86/atomic-machine.h
+++ b/sysdeps/x86/atomic-machine.h
@@ -19,9 +19,6 @@
#ifndef _X86_ATOMIC_MACHINE_H
#define _X86_ATOMIC_MACHINE_H 1
-#include <stdint.h>
-#include <libc-pointer-arith.h> /* For cast_to_integer. */
-
#define USE_ATOMIC_COMPILER_BUILTINS 1
#ifdef __x86_64__
@@ -41,32 +38,8 @@
#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
(! __sync_bool_compare_and_swap (mem, oldval, newval))
-/* Note that we need no lock prefix. */
#define atomic_exchange_acq(mem, newvalue) \
- ({ __typeof (*mem) result; \
- if (sizeof (*mem) == 1) \
- __asm __volatile ("xchgb %b0, %1" \
- : "=q" (result), "=m" (*mem) \
- : "0" (newvalue), "m" (*mem)); \
- else if (sizeof (*mem) == 2) \
- __asm __volatile ("xchgw %w0, %1" \
- : "=r" (result), "=m" (*mem) \
- : "0" (newvalue), "m" (*mem)); \
- else if (sizeof (*mem) == 4) \
- __asm __volatile ("xchgl %0, %1" \
- : "=r" (result), "=m" (*mem) \
- : "0" (newvalue), "m" (*mem)); \
- else if (__HAVE_64B_ATOMICS) \
- __asm __volatile ("xchgq %q0, %1" \
- : "=r" (result), "=m" (*mem) \
- : "0" ((int64_t) cast_to_integer (newvalue)), \
- "m" (*mem)); \
- else \
- { \
- result = 0; \
- __atomic_link_error (); \
- } \
- result; })
+ __atomic_exchange_n (mem, newvalue, __ATOMIC_ACQUIRE)
/* ??? Remove when catomic_exchange_and_add
fallback uses __atomic_fetch_add. */