Message ID | AM5PR0801MB16685212691A165C68F70F1183969@AM5PR0801MB1668.eurprd08.prod.outlook.com |
---|---|
State | New |
Headers | show |
Series | Remove atomic-machine headers | expand |
* Wilco Dijkstra via Libc-alpha: > diff --git a/configure b/configure > index ff2c406b3b573484c843742d292fc2e0ee0e3008..3efdf45f99af71a482509f559d9de90aa294700c 100755 > --- a/configure > +++ b/configure > @@ -727,6 +727,7 @@ infodir > docdir > oldincludedir > includedir > +runstatedir > localstatedir > sharedstatedir > sysconfdir Spurious difference. > +typedef struct { long long t; } X; > +extern void has_64b_atomics(void); > +void f(void) > +{ > + X x; > + /* Use address of structure with 64-bit type. This avoids incorrect > + implementations which return true even if long long is not 64-bit aligned. > + This works on GCC and LLVM - other cases have bugs and they disagree. */ > + if (__atomic_always_lock_free (sizeof (x), &x)) > + has_64b_atomics(); Can you use _static_assert, given that it's supposed to yield a compile-time constant? I'd be suprised if __atomic_always_lock_free is correct on all glibc-supported architectures, though. > diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h > index 98541a2d06ff5e4aa8c789ab7405215097471971..303458d1296e4b1cd7cd654e0904ace0ffc52fae 100644 > --- a/sysdeps/x86/atomic-machine.h > +++ b/sysdeps/x86/atomic-machine.h > @@ -21,17 +21,6 @@ > > #include <tls.h> /* For mach. */ > > -#ifdef __x86_64__ > -# define __HAVE_64B_ATOMICS 1 > -#else > -/* Since the Pentium, i386 CPUs have supported 64-bit atomics, but the > - i386 psABI supplement provides only 4-byte alignment for uint64_t > - inside structs, so it is currently not possible to use 64-bit > - atomics on this platform. */ > -# define __HAVE_64B_ATOMICS 0 > -#endif > -#define ATOMIC_EXCHANGE_USES_CAS 0 > - > #define atomic_spin_nop() __asm ("pause") > > #endif /* atomic-machine.h */ Please preserve this comment somewhere. Maybe folod it into the configure test example. Thanks, Florian
Hi Florian, >> +runstatedir > > Spurious difference. I've removed it from v2, but it reappears whenever I run autoconf... > Can you use _static_assert, given that it's supposed to yield a > compile-time constant? Yes that works fine. I've also used that in include/atomic.h so you get better error messages if it does fail. > I'd be suprised if __atomic_always_lock_free is correct on all > glibc-supported architectures, though. It passes build-many-glibcs, so it works well enough. I double-checked the config output, and it is as expected: 64-bit targets say yes, 32-bit targets say no except for armv7-a (which is correct). > -/* Since the Pentium, i386 CPUs have supported 64-bit atomics, but the > - i386 psABI supplement provides only 4-byte alignment for uint64_t > - inside structs, so it is currently not possible to use 64-bit > - atomics on this platform. */ > Please preserve this comment somewhere. Maybe folod it into the > configure test example. This comment is in the configure test: > + /* Use address of structure with 64-bit type. This avoids incorrect > + implementations which return true even if long long is not 64-bit aligned. > + This works on GCC and LLVM - other cases have bugs and they disagree. */ This is more generic since unaligned 64-bit types are common on many 32-bit targets. Cheers, Wilco v2: Add llongarch, fix leon3, use _Static_assert Remove the last few unnecessary defines from all the atomic-machine headers so almost all can be removed. Set __HAVE_64B_ATOMICS as part of configure - this is not only simpler but also more correct since it depends on the compiler and settings. Note that __atomic_always_lock_free is quite buggy, but the expression used works correctly, including on LLVM. Remove the odd ATOMIC_EXCHANGE_USES_CAS as it is only used once and set incorrectly by many targets. Passes regress on AArch64 and buildmanyglibc. --- diff --git a/config.h.in b/config.h.in index 43d32518ab34c048d51f2586ed1762c95d14ef68..a7607a3ddfaedd014c8890100ef76795888a10be 100644 --- a/config.h.in +++ b/config.h.in @@ -292,4 +292,7 @@ /* Define if -mmovbe is enabled by default on x86. */ #undef HAVE_X86_MOVBE +/* Set to 1 if 64 bit atomics are supported. */ +#define __HAVE_64B_ATOMICS 0 + #endif diff --git a/configure b/configure index ff2c406b3b573484c843742d292fc2e0ee0e3008..fdbc9a6c2e6b84ff60e833eaf2719310444a5dac 100755 --- a/configure +++ b/configure @@ -6316,6 +6316,43 @@ if test "$libc_cv_gcc_builtin_memset" = yes ; then fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit atomic support" >&5 +$as_echo_n "checking for 64-bit atomic support... " >&6; } +if ${libc_cv_gcc_has_64b_atomics+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat > conftest.c <<\EOF +typedef struct { long long t; } X; +extern void has_64b_atomics(void); +void f(void) +{ + X x; + /* Use address of structure with 64-bit type. This avoids incorrect + implementations which return true even if long long is not 64-bit aligned. + This works on GCC and LLVM - other cases have bugs and they disagree. */ + _Static_assert (__atomic_always_lock_free (sizeof (x), &x), "no_64b_atomics"); +} +EOF +if { ac_try='${CC-cc} -O2 -S conftest.c' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; +then + libc_cv_gcc_has_64b_atomics=yes +else + libc_cv_gcc_has_64b_atomics=no +fi +rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_gcc_has_64b_atomics" >&5 +$as_echo "$libc_cv_gcc_has_64b_atomics" >&6; } +if test "$libc_cv_gcc_has_64b_atomics" = yes; then + $as_echo "#define __HAVE_64B_ATOMICS 1" >>confdefs.h + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for redirection of built-in functions" >&5 $as_echo_n "checking for redirection of built-in functions... " >&6; } if ${libc_cv_gcc_builtin_redirection+:} false; then : diff --git a/configure.ac b/configure.ac index eb5bc6a1313acb3f3614645739adeb7638f19617..ab1a248f50e7a4c0e36f8af6e2d6f7d8bf4c1787 100644 --- a/configure.ac +++ b/configure.ac @@ -1443,6 +1443,31 @@ if test "$libc_cv_gcc_builtin_memset" = yes ; then AC_DEFINE(HAVE_BUILTIN_MEMSET) fi +AC_CACHE_CHECK(for 64-bit atomic support, libc_cv_gcc_has_64b_atomics, [dnl +cat > conftest.c <<\EOF +typedef struct { long long t; } X; +extern void has_64b_atomics(void); +void f(void) +{ + X x; + /* Use address of structure with 64-bit type. This avoids incorrect + implementations which return true even if long long is not 64-bit aligned. + This works on GCC and LLVM - other cases have bugs and they disagree. */ + _Static_assert (__atomic_always_lock_free (sizeof (x), &x), "no_64b_atomics"); +} +EOF +dnl +if AC_TRY_COMMAND([${CC-cc} -O2 -S conftest.c]); +then + libc_cv_gcc_has_64b_atomics=yes +else + libc_cv_gcc_has_64b_atomics=no +fi +rm -f conftest* ]) +if test "$libc_cv_gcc_has_64b_atomics" = yes; then + AC_DEFINE(__HAVE_64B_ATOMICS, 1) +fi + AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl cat > conftest.c <<\EOF extern char *strstr (const char *, const char *) __asm ("my_strstr"); diff --git a/include/atomic.h b/include/atomic.h index e9ec063228b5aeeccb4c5d14d7c894f00617eefb..4494650f03d20299dcf0d6ee314e93ed7fcf7043 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -27,11 +27,6 @@ - support functions like barriers. They also have the prefix "atomic_". - Architectures must provide a few lowlevel macros (the compare - and exchange definitions). All others are optional. They - should only be provided if the architecture has specific - support for the operation. - As <atomic.h> macros are usually heavily nested and often use local variables to make sure side-effects are evaluated properly, use for macro local variables a per-macro unique prefix. This file uses @@ -74,43 +69,17 @@ __atg11_oldval; }) #endif - -/* This is equal to 1 iff the architecture supports 64b atomic operations. */ -#ifndef __HAVE_64B_ATOMICS -#error Unable to determine if 64-bit atomics are present. -#endif - /* The following functions are a subset of the atomic operations provided by C11. Usually, a function named atomic_OP_MO(args) is equivalent to C11's atomic_OP_explicit(args, memory_order_MO); exceptions noted below. */ - -/* We require 32b atomic operations; some archs also support 64b atomic - operations. */ -void __atomic_link_error (void); -# if __HAVE_64B_ATOMICS == 1 -# define __atomic_check_size(mem) \ - if ((sizeof (*mem) != 4) && (sizeof (*mem) != 8)) \ - __atomic_link_error (); -# else -# define __atomic_check_size(mem) \ - if (sizeof (*mem) != 4) \ - __atomic_link_error (); -# endif -/* We additionally provide 8b and 16b atomic loads and stores; we do not yet - need other atomic operations of such sizes, and restricting the support to - loads and stores makes this easier for archs that do not have native - support for atomic operations to less-than-word-sized data. */ -# if __HAVE_64B_ATOMICS == 1 -# define __atomic_check_size_ls(mem) \ - if ((sizeof (*mem) != 1) && (sizeof (*mem) != 2) && (sizeof (*mem) != 4) \ - && (sizeof (*mem) != 8)) \ - __atomic_link_error (); -# else -# define __atomic_check_size_ls(mem) \ - if ((sizeof (*mem) != 1) && (sizeof (*mem) != 2) && sizeof (*mem) != 4) \ - __atomic_link_error (); -# endif +/* Check atomic operations are lock free. Since this doesn't work correctly + on all targets (eg. if uint64_t is 4-byte aligned), use__HAVE_64B_ATOMICS + for 64-bit types. */ +#define __atomic_check_size(mem) \ + _Static_assert (__atomic_always_lock_free (sizeof (*(mem)), 0) && \ + !(sizeof (*(mem)) == 8 && __HAVE_64B_ATOMICS == 0), \ + "atomic not lock free!") # define atomic_thread_fence_acquire() \ __atomic_thread_fence (__ATOMIC_ACQUIRE) @@ -120,20 +89,20 @@ void __atomic_link_error (void); __atomic_thread_fence (__ATOMIC_SEQ_CST) # define atomic_load_relaxed(mem) \ - ({ __atomic_check_size_ls((mem)); \ + ({ __atomic_check_size ((mem)); \ __atomic_load_n ((mem), __ATOMIC_RELAXED); }) # define atomic_load_acquire(mem) \ - ({ __atomic_check_size_ls((mem)); \ + ({ __atomic_check_size ((mem)); \ __atomic_load_n ((mem), __ATOMIC_ACQUIRE); }) # define atomic_store_relaxed(mem, val) \ do { \ - __atomic_check_size_ls((mem)); \ + __atomic_check_size ((mem)); \ __atomic_store_n ((mem), (val), __ATOMIC_RELAXED); \ } while (0) # define atomic_store_release(mem, val) \ do { \ - __atomic_check_size_ls((mem)); \ + __atomic_check_size ((mem)); \ __atomic_store_n ((mem), (val), __ATOMIC_RELEASE); \ } while (0) @@ -218,12 +187,4 @@ void __atomic_link_error (void); # define atomic_spin_nop() do { /* nothing */ } while (0) #endif -/* ATOMIC_EXCHANGE_USES_CAS is non-zero if atomic_exchange operations - are implemented based on a CAS loop; otherwise, this is zero and we assume - that the atomic_exchange operations could provide better performance - than a CAS loop. */ -#ifndef ATOMIC_EXCHANGE_USES_CAS -# error ATOMIC_EXCHANGE_USES_CAS has to be defined. -#endif - #endif /* atomic.h */ diff --git a/nptl/pthread_spin_lock.c b/nptl/pthread_spin_lock.c index 19d1759f9aa350d5a711ac8abe6f9db1464a1012..9122a260303a4356d7ee68274f04b542090de380 100644 --- a/nptl/pthread_spin_lock.c +++ b/nptl/pthread_spin_lock.c @@ -26,29 +26,12 @@ __pthread_spin_lock (pthread_spinlock_t *lock) int val = 0; /* We assume that the first try mostly will be successful, thus we use - atomic_exchange if it is not implemented by a CAS loop (we also assume - that atomic_exchange can be faster if it succeeds, see - ATOMIC_EXCHANGE_USES_CAS). Otherwise, we use a weak CAS and not an - exchange so we bail out after the first failed attempt to change the - state. For the subsequent attempts we use atomic_compare_and_exchange - after we observe that the lock is not acquired. - See also comment in pthread_spin_trylock. + atomic_exchange. We use acquire MO to synchronize-with the release MO store in pthread_spin_unlock, and thus ensure that prior critical sections happen-before this critical section. */ -#if ! ATOMIC_EXCHANGE_USES_CAS - /* Try to acquire the lock with an exchange instruction as this architecture - has such an instruction and we assume it is faster than a CAS. - The acquisition succeeds if the lock is not in an acquired state. */ if (__glibc_likely (atomic_exchange_acquire (lock, 1) == 0)) return 0; -#else - /* Try to acquire the lock with a CAS instruction as this architecture - has no exchange instruction. The acquisition succeeds if the lock is not - acquired. */ - if (__glibc_likely (atomic_compare_exchange_weak_acquire (lock, &val, 1))) - return 0; -#endif do { diff --git a/nptl/pthread_spin_trylock.c b/nptl/pthread_spin_trylock.c index f2b12f9b4fe34340c9a2e449f2652908a7ff469d..3bd870401cdb336fe05469c3944b82fa563869be 100644 --- a/nptl/pthread_spin_trylock.c +++ b/nptl/pthread_spin_trylock.c @@ -24,57 +24,8 @@ int __pthread_spin_trylock (pthread_spinlock_t *lock) { - /* For the spin try lock, we have the following possibilities: - - 1) If we assume that trylock will most likely succeed in practice: - * We just do an exchange. - - 2) If we want to bias towards cases where trylock succeeds, but don't - rule out contention: - * If exchange is not implemented by a CAS loop, and exchange is faster - than CAS, do an exchange. - * If exchange is implemented by a CAS loop, use a weak CAS and not an - exchange so we bail out after the first failed attempt to change the state. - - 3) If we expect contention to be likely: - * If CAS always brings the cache line into an exclusive state even if the - spinlock is already acquired, then load the value first with - atomic_load_relaxed and test if lock is not acquired. Then do 2). - - We assume that 2) is the common case, and that this won't be slower than - 1) in the common case. - - We use acquire MO to synchronize-with the release MO store in - pthread_spin_unlock, and thus ensure that prior critical sections - happen-before this critical section. */ -#if ! ATOMIC_EXCHANGE_USES_CAS - /* Try to acquire the lock with an exchange instruction as this architecture - has such an instruction and we assume it is faster than a CAS. - The acquisition succeeds if the lock is not in an acquired state. */ if (atomic_exchange_acquire (lock, 1) == 0) return 0; -#else - /* Try to acquire the lock with a CAS instruction as this architecture - has no exchange instruction. The acquisition succeeds if the lock is not - acquired. */ - do - { - int val = 0; - if (atomic_compare_exchange_weak_acquire (lock, &val, 1)) - return 0; - } - /* atomic_compare_exchange_weak_acquire can fail spuriously. Whereas - C++11 and C11 make it clear that trylock operations can fail spuriously, - POSIX does not explicitly specify this; it only specifies that failing - synchronization operations do not need to have synchronization effects - themselves, but a spurious failure is something that could contradict a - happens-before established earlier (e.g., that we need to observe that - the lock is acquired). Therefore, we emulate a strong CAS by simply - checking with a relaxed MO load that the lock is really acquired before - returning EBUSY; the additional overhead this may cause is on the slow - path. */ - while (atomic_load_relaxed (lock) == 0); -#endif return EBUSY; } diff --git a/sysdeps/aarch64/atomic-machine.h b/sysdeps/aarch64/atomic-machine.h deleted file mode 100644 index 2dc1c524e40e2e805161e6d9b1b385b85c53a5c8..0000000000000000000000000000000000000000 --- a/sysdeps/aarch64/atomic-machine.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _AARCH64_ATOMIC_MACHINE_H -#define _AARCH64_ATOMIC_MACHINE_H 1 - -#define __HAVE_64B_ATOMICS 1 -#define ATOMIC_EXCHANGE_USES_CAS 0 - -#endif diff --git a/sysdeps/alpha/atomic-machine.h b/sysdeps/alpha/atomic-machine.h deleted file mode 100644 index 7fbe5b87eebf323d38fe1349b02aa56fe199cab3..0000000000000000000000000000000000000000 --- a/sysdeps/alpha/atomic-machine.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#include <stdint.h> - -#define __HAVE_64B_ATOMICS 1 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/arc/atomic-machine.h b/sysdeps/arc/atomic-machine.h deleted file mode 100644 index 2d519e3bbfa9ce77f4a41e313b67a690569d032e..0000000000000000000000000000000000000000 --- a/sysdeps/arc/atomic-machine.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Low-level functions for atomic operations. ARC version. - Copyright (C) 2020-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _ARC_BITS_ATOMIC_H -#define _ARC_BITS_ATOMIC_H 1 - -#define __HAVE_64B_ATOMICS 0 - -/* ARC does have legacy atomic EX reg, [mem] instruction but the micro-arch - is not as optimal as LLOCK/SCOND specially for SMP. */ -#define ATOMIC_EXCHANGE_USES_CAS 1 - -#endif /* _ARC_BITS_ATOMIC_H */ diff --git a/sysdeps/arm/atomic-machine.h b/sysdeps/arm/atomic-machine.h deleted file mode 100644 index b172573ae74dc9d6c7618bfdb76f5fb0429469f8..0000000000000000000000000000000000000000 --- a/sysdeps/arm/atomic-machine.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Atomic operations. Pure ARM version. - Copyright (C) 2002-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#define __HAVE_64B_ATOMICS 0 -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/csky/atomic-machine.h b/sysdeps/csky/atomic-machine.h deleted file mode 100644 index 4a7dc63be2044990852c52500943c90c898363be..0000000000000000000000000000000000000000 --- a/sysdeps/csky/atomic-machine.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Atomic operations. C-SKY version. - Copyright (C) 2018-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef __CSKY_ATOMIC_H_ -#define __CSKY_ATOMIC_H_ - -#define __HAVE_64B_ATOMICS 0 -#define ATOMIC_EXCHANGE_USES_CAS 1 - -#endif /* atomic-machine.h */ diff --git a/sysdeps/ia64/atomic-machine.h b/sysdeps/ia64/atomic-machine.h deleted file mode 100644 index 6f31c7b2eea67b5d8766dea1c38df6eedc168ebf..0000000000000000000000000000000000000000 --- a/sysdeps/ia64/atomic-machine.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#include <ia64intrin.h> - -#define __HAVE_64B_ATOMICS 1 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 0 diff --git a/sysdeps/m68k/coldfire/atomic-machine.h b/sysdeps/m68k/coldfire/atomic-machine.h deleted file mode 100644 index 1503703ed36b825f6e9f2cb2ed1516cd80bd9947..0000000000000000000000000000000000000000 --- a/sysdeps/m68k/coldfire/atomic-machine.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _ATOMIC_MACHINE_H -#define _ATOMIC_MACHINE_H 1 - -/* If we have just non-atomic operations, we can as well make them wide. */ -#define __HAVE_64B_ATOMICS 1 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 - -#endif diff --git a/sysdeps/m68k/m680x0/m68020/atomic-machine.h b/sysdeps/m68k/m680x0/m68020/atomic-machine.h deleted file mode 100644 index d356b55c9f9082db8dde734c254e01a631201206..0000000000000000000000000000000000000000 --- a/sysdeps/m68k/m680x0/m68020/atomic-machine.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -/* GCC does not support lock-free 64-bit atomic_load/store. */ -#define __HAVE_64B_ATOMICS 0 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/microblaze/atomic-machine.h b/sysdeps/microblaze/atomic-machine.h deleted file mode 100644 index 4e7ccce21e59453f5233bdf82b22215d9a6d17b3..0000000000000000000000000000000000000000 --- a/sysdeps/microblaze/atomic-machine.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#include <sysdep.h> - -#define __HAVE_64B_ATOMICS 0 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/mips/atomic-machine.h b/sysdeps/mips/atomic-machine.h deleted file mode 100644 index 1e611c2153996d28e14611c60189f52d0919b79c..0000000000000000000000000000000000000000 --- a/sysdeps/mips/atomic-machine.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Low-level functions for atomic operations. Mips version. - Copyright (C) 2005-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _MIPS_ATOMIC_MACHINE_H -#define _MIPS_ATOMIC_MACHINE_H 1 - -#include <sgidefs.h> - -#if _MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIN32 -#define __HAVE_64B_ATOMICS 0 -#else -#define __HAVE_64B_ATOMICS 1 -#endif - -/* MIPS is an LL/SC machine. However, XLP has a direct atomic exchange - instruction which will be used by __atomic_exchange_n. */ -#ifdef _MIPS_ARCH_XLP -# define ATOMIC_EXCHANGE_USES_CAS 0 -#else -# define ATOMIC_EXCHANGE_USES_CAS 1 -#endif - -#endif /* atomic-machine.h */ diff --git a/sysdeps/or1k/atomic-machine.h b/sysdeps/or1k/atomic-machine.h deleted file mode 100644 index 90a10867b3f9cf97a0f2f521f6759a0008ef5b82..0000000000000000000000000000000000000000 --- a/sysdeps/or1k/atomic-machine.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Atomic operations. OpenRISC version. - Copyright (C) 2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef __OR1K_ATOMIC_H_ -#define __OR1K_ATOMIC_H_ - -#include <stdint.h> - -#define __HAVE_64B_ATOMICS 0 -#define ATOMIC_EXCHANGE_USES_CAS 1 - -#endif /* atomic-machine.h */ diff --git a/sysdeps/powerpc/powerpc32/atomic-machine.h b/sysdeps/powerpc/powerpc32/atomic-machine.h index 6a2aae8bdb34281144e6810924377a6a62857d15..5d1d1ca120530371daaf97d5d0c5b545b2327a78 100644 --- a/sysdeps/powerpc/powerpc32/atomic-machine.h +++ b/sysdeps/powerpc/powerpc32/atomic-machine.h @@ -33,6 +33,3 @@ #endif #define __ARCH_ACQ_INSTR "isync" - -#define __HAVE_64B_ATOMICS 0 -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/powerpc/powerpc64/atomic-machine.h b/sysdeps/powerpc/powerpc64/atomic-machine.h index 2932f889c5bc6d0fa49d5ad36875b50c27ad07e9..cdee4b84827bcb8455972302725edb3fb76a744c 100644 --- a/sysdeps/powerpc/powerpc64/atomic-machine.h +++ b/sysdeps/powerpc/powerpc64/atomic-machine.h @@ -33,6 +33,3 @@ #endif #define __ARCH_ACQ_INSTR "isync" - -#define __HAVE_64B_ATOMICS 1 -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/s390/atomic-machine.h b/sysdeps/s390/atomic-machine.h deleted file mode 100644 index 3e25dcf44126001382e3b98aa2f82d29e29f1424..0000000000000000000000000000000000000000 --- a/sysdeps/s390/atomic-machine.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#ifdef __s390x__ -# define __HAVE_64B_ATOMICS 1 -#else -# define __HAVE_64B_ATOMICS 0 -#endif - -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/sparc/atomic-machine.h b/sysdeps/sparc/atomic-machine.h index 1f0eb0a9b1171c06dc19dc21c4fe7de94adc4bce..7ea88d598b9a36735004fe03cb52e46fe4807140 100644 --- a/sysdeps/sparc/atomic-machine.h +++ b/sysdeps/sparc/atomic-machine.h @@ -19,15 +19,6 @@ #ifndef _ATOMIC_MACHINE_H #define _ATOMIC_MACHINE_H 1 -#ifdef __arch64__ -# define __HAVE_64B_ATOMICS 1 -#else -# define __HAVE_64B_ATOMICS 0 -#endif - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS __HAVE_64B_ATOMICS - #ifdef __sparc_v9__ extern void __cpu_relax (void); diff --git a/sysdeps/unix/sysv/linux/hppa/atomic-machine.h b/sysdeps/unix/sysv/linux/hppa/atomic-machine.h deleted file mode 100644 index 9c9fecbefef037e3b7e8c291e722d093b811dd69..0000000000000000000000000000000000000000 --- a/sysdeps/unix/sysv/linux/hppa/atomic-machine.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _ATOMIC_MACHINE_H -#define _ATOMIC_MACHINE_H 1 - -#define __HAVE_64B_ATOMICS 0 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 - -#endif -/* _ATOMIC_MACHINE_H */ diff --git a/sysdeps/unix/sysv/linux/loongarch/atomic-machine.h b/sysdeps/unix/sysv/linux/loongarch/atomic-machine.h deleted file mode 100644 index c94144605fcd16c1dd3e35a86eb325e1acb4d282..0000000000000000000000000000000000000000 --- a/sysdeps/unix/sysv/linux/loongarch/atomic-machine.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Atomic operations. - Copyright (C) 2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _LINUX_LOONGARCH_BITS_ATOMIC_H -#define _LINUX_LOONGARCH_BITS_ATOMIC_H 1 - -#define atomic_full_barrier() __sync_synchronize () - -#define __HAVE_64B_ATOMICS (__loongarch_grlen >= 64) -#define ATOMIC_EXCHANGE_USES_CAS 0 - -#endif /* bits/atomic.h */ diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h b/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h deleted file mode 100644 index 02e54847a42bfbc93ae1e07b7e32965be644daba..0000000000000000000000000000000000000000 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2010-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _ATOMIC_MACHINE_H -#define _ATOMIC_MACHINE_H 1 - -#include <sysdep.h> - -#define __HAVE_64B_ATOMICS 0 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 - -#endif diff --git a/sysdeps/unix/sysv/linux/nios2/atomic-machine.h b/sysdeps/unix/sysv/linux/nios2/atomic-machine.h deleted file mode 100644 index 4b4b714f93f4c4b9f7f650d70d2301299a45e2f5..0000000000000000000000000000000000000000 --- a/sysdeps/unix/sysv/linux/nios2/atomic-machine.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Low-level functions for atomic operations. Nios II version. - Copyright (C) 2012-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _NIOS2_ATOMIC_MACHINE_H -#define _NIOS2_ATOMIC_MACHINE_H 1 - -#define __HAVE_64B_ATOMICS 0 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 - -#endif /* _NIOS2_ATOMIC_MACHINE_H */ diff --git a/sysdeps/unix/sysv/linux/riscv/atomic-machine.h b/sysdeps/unix/sysv/linux/riscv/atomic-machine.h index b0ebe09ce1fa4e15064dd57d83cadb8a1976f86d..90c48b301e8dad46017fe8d6497756cdd74268c8 100644 --- a/sysdeps/unix/sysv/linux/riscv/atomic-machine.h +++ b/sysdeps/unix/sysv/linux/riscv/atomic-machine.h @@ -21,9 +21,6 @@ #ifdef __riscv_atomic -# define __HAVE_64B_ATOMICS (__riscv_xlen >= 64) -# define ATOMIC_EXCHANGE_USES_CAS 0 - /* Miscellaneous. */ # define asm_amo(which, ordering, mem, value) ({ \ diff --git a/sysdeps/unix/sysv/linux/sh/atomic-machine.h b/sysdeps/unix/sysv/linux/sh/atomic-machine.h deleted file mode 100644 index 71848194daa98ad0391c029a8c7d9dba5ba5fe3d..0000000000000000000000000000000000000000 --- a/sysdeps/unix/sysv/linux/sh/atomic-machine.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Atomic operations used inside libc. Linux/SH version. - Copyright (C) 2003-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#define __HAVE_64B_ATOMICS 0 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile b/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile index 21c7dc1680caf19cb21a36ade3cb4baaee188159..1b8b1c516ac1e70b36650e00f06c8d2425a4d882 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile @@ -11,7 +11,7 @@ endif # When I get this to work, this is the right thing ifeq ($(subdir),elf) -CFLAGS-rtld.c += -mcpu=v8 +#CFLAGS-rtld.c += -mcpu=v8 # causes leon3 builds to fail #rtld-routines += dl-sysdepsparc sysdep-others += lddlibc4 install-bin += lddlibc4 diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h index 98541a2d06ff5e4aa8c789ab7405215097471971..303458d1296e4b1cd7cd654e0904ace0ffc52fae 100644 --- a/sysdeps/x86/atomic-machine.h +++ b/sysdeps/x86/atomic-machine.h @@ -21,17 +21,6 @@ #include <tls.h> /* For mach. */ -#ifdef __x86_64__ -# define __HAVE_64B_ATOMICS 1 -#else -/* Since the Pentium, i386 CPUs have supported 64-bit atomics, but the - i386 psABI supplement provides only 4-byte alignment for uint64_t - inside structs, so it is currently not possible to use 64-bit - atomics on this platform. */ -# define __HAVE_64B_ATOMICS 0 -#endif -#define ATOMIC_EXCHANGE_USES_CAS 0 - #define atomic_spin_nop() __asm ("pause") #endif /* atomic-machine.h */
diff --git a/config.h.in b/config.h.in index bf316439a03ed23091b6bee6dea25ed61d0b8d0f..83b5a3a4bda77da0a8f582a52db78b0bea1725a9 100644 --- a/config.h.in +++ b/config.h.in @@ -286,4 +286,7 @@ /* Define if -mmovbe is enabled by default on x86. */ #undef HAVE_X86_MOVBE +/* Set to 1 if 64 bit atomics are supported. */ +#define __HAVE_64B_ATOMICS 0 + #endif diff --git a/configure b/configure index ff2c406b3b573484c843742d292fc2e0ee0e3008..3efdf45f99af71a482509f559d9de90aa294700c 100755 --- a/configure +++ b/configure @@ -727,6 +727,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -841,6 +842,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1093,6 +1095,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1230,7 +1241,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1383,6 +1394,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -6316,6 +6328,44 @@ if test "$libc_cv_gcc_builtin_memset" = yes ; then fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit atomic support" >&5 +$as_echo_n "checking for 64-bit atomic support... " >&6; } +if ${libc_cv_gcc_has_64b_atomics+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat > conftest.c <<\EOF +typedef struct { long long t; } X; +extern void has_64b_atomics(void); +void f(void) +{ + X x; + /* Use address of structure with 64-bit type. This avoids incorrect + implementations which return true even if long long is not 64-bit aligned. + This works on GCC and LLVM - other cases have bugs and they disagree. */ + if (__atomic_always_lock_free (sizeof (x), &x)) + has_64b_atomics(); +} +EOF +if { ac_try='${CC-cc} -O3 -S conftest.c -o - | grep -F "has_64b_atomics" > /dev/null' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; +then + libc_cv_gcc_has_64b_atomics=yes +else + libc_cv_gcc_has_64b_atomics=no +fi +rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_gcc_has_64b_atomics" >&5 +$as_echo "$libc_cv_gcc_has_64b_atomics" >&6; } +if test "$libc_cv_gcc_has_64b_atomics" = yes; then + $as_echo "#define __HAVE_64B_ATOMICS 1" >>confdefs.h + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for redirection of built-in functions" >&5 $as_echo_n "checking for redirection of built-in functions... " >&6; } if ${libc_cv_gcc_builtin_redirection+:} false; then : diff --git a/configure.ac b/configure.ac index eb5bc6a1313acb3f3614645739adeb7638f19617..9e02b82d5215a05ac9ac0aea62da33efddab40f4 100644 --- a/configure.ac +++ b/configure.ac @@ -1443,6 +1443,32 @@ if test "$libc_cv_gcc_builtin_memset" = yes ; then AC_DEFINE(HAVE_BUILTIN_MEMSET) fi +AC_CACHE_CHECK(for 64-bit atomic support, libc_cv_gcc_has_64b_atomics, [dnl +cat > conftest.c <<\EOF +typedef struct { long long t; } X; +extern void has_64b_atomics(void); +void f(void) +{ + X x; + /* Use address of structure with 64-bit type. This avoids incorrect + implementations which return true even if long long is not 64-bit aligned. + This works on GCC and LLVM - other cases have bugs and they disagree. */ + if (__atomic_always_lock_free (sizeof (x), &x)) + has_64b_atomics(); +} +EOF +dnl +if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "has_64b_atomics" > /dev/null]); +then + libc_cv_gcc_has_64b_atomics=yes +else + libc_cv_gcc_has_64b_atomics=no +fi +rm -f conftest* ]) +if test "$libc_cv_gcc_has_64b_atomics" = yes; then + AC_DEFINE(__HAVE_64B_ATOMICS, 1) +fi + AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl cat > conftest.c <<\EOF extern char *strstr (const char *, const char *) __asm ("my_strstr"); diff --git a/include/atomic.h b/include/atomic.h index e9ec063228b5aeeccb4c5d14d7c894f00617eefb..48cc222e0325bfdbbfb64b4100e7d3c03f47dc05 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -27,11 +27,6 @@ - support functions like barriers. They also have the prefix "atomic_". - Architectures must provide a few lowlevel macros (the compare - and exchange definitions). All others are optional. They - should only be provided if the architecture has specific - support for the operation. - As <atomic.h> macros are usually heavily nested and often use local variables to make sure side-effects are evaluated properly, use for macro local variables a per-macro unique prefix. This file uses @@ -74,43 +69,18 @@ __atg11_oldval; }) #endif - -/* This is equal to 1 iff the architecture supports 64b atomic operations. */ -#ifndef __HAVE_64B_ATOMICS -#error Unable to determine if 64-bit atomics are present. -#endif - /* The following functions are a subset of the atomic operations provided by C11. Usually, a function named atomic_OP_MO(args) is equivalent to C11's atomic_OP_explicit(args, memory_order_MO); exceptions noted below. */ - -/* We require 32b atomic operations; some archs also support 64b atomic - operations. */ +/* Check atomic operations are lock free. Since this doesn't work correctly + on all targets (eg. if uint64_t is 4-byte aligned), use__HAVE_64B_ATOMICS + for 64-bit types. */ void __atomic_link_error (void); -# if __HAVE_64B_ATOMICS == 1 -# define __atomic_check_size(mem) \ - if ((sizeof (*mem) != 4) && (sizeof (*mem) != 8)) \ - __atomic_link_error (); -# else -# define __atomic_check_size(mem) \ - if (sizeof (*mem) != 4) \ - __atomic_link_error (); -# endif -/* We additionally provide 8b and 16b atomic loads and stores; we do not yet - need other atomic operations of such sizes, and restricting the support to - loads and stores makes this easier for archs that do not have native - support for atomic operations to less-than-word-sized data. */ -# if __HAVE_64B_ATOMICS == 1 -# define __atomic_check_size_ls(mem) \ - if ((sizeof (*mem) != 1) && (sizeof (*mem) != 2) && (sizeof (*mem) != 4) \ - && (sizeof (*mem) != 8)) \ - __atomic_link_error (); -# else -# define __atomic_check_size_ls(mem) \ - if ((sizeof (*mem) != 1) && (sizeof (*mem) != 2) && sizeof (*mem) != 4) \ - __atomic_link_error (); -# endif +#define __atomic_check_size(mem) \ + if (!__atomic_always_lock_free (sizeof (*(mem)), 0) || \ + (sizeof (*(mem)) == 8 && __HAVE_64B_ATOMICS == 0)) \ + __atomic_link_error (); # define atomic_thread_fence_acquire() \ __atomic_thread_fence (__ATOMIC_ACQUIRE) @@ -120,20 +90,20 @@ void __atomic_link_error (void); __atomic_thread_fence (__ATOMIC_SEQ_CST) # define atomic_load_relaxed(mem) \ - ({ __atomic_check_size_ls((mem)); \ + ({ __atomic_check_size ((mem)); \ __atomic_load_n ((mem), __ATOMIC_RELAXED); }) # define atomic_load_acquire(mem) \ - ({ __atomic_check_size_ls((mem)); \ + ({ __atomic_check_size ((mem)); \ __atomic_load_n ((mem), __ATOMIC_ACQUIRE); }) # define atomic_store_relaxed(mem, val) \ do { \ - __atomic_check_size_ls((mem)); \ + __atomic_check_size ((mem)); \ __atomic_store_n ((mem), (val), __ATOMIC_RELAXED); \ } while (0) # define atomic_store_release(mem, val) \ do { \ - __atomic_check_size_ls((mem)); \ + __atomic_check_size ((mem)); \ __atomic_store_n ((mem), (val), __ATOMIC_RELEASE); \ } while (0) @@ -218,12 +188,4 @@ void __atomic_link_error (void); # define atomic_spin_nop() do { /* nothing */ } while (0) #endif -/* ATOMIC_EXCHANGE_USES_CAS is non-zero if atomic_exchange operations - are implemented based on a CAS loop; otherwise, this is zero and we assume - that the atomic_exchange operations could provide better performance - than a CAS loop. */ -#ifndef ATOMIC_EXCHANGE_USES_CAS -# error ATOMIC_EXCHANGE_USES_CAS has to be defined. -#endif - #endif /* atomic.h */ diff --git a/nptl/pthread_spin_lock.c b/nptl/pthread_spin_lock.c index 19d1759f9aa350d5a711ac8abe6f9db1464a1012..9122a260303a4356d7ee68274f04b542090de380 100644 --- a/nptl/pthread_spin_lock.c +++ b/nptl/pthread_spin_lock.c @@ -26,29 +26,12 @@ __pthread_spin_lock (pthread_spinlock_t *lock) int val = 0; /* We assume that the first try mostly will be successful, thus we use - atomic_exchange if it is not implemented by a CAS loop (we also assume - that atomic_exchange can be faster if it succeeds, see - ATOMIC_EXCHANGE_USES_CAS). Otherwise, we use a weak CAS and not an - exchange so we bail out after the first failed attempt to change the - state. For the subsequent attempts we use atomic_compare_and_exchange - after we observe that the lock is not acquired. - See also comment in pthread_spin_trylock. + atomic_exchange. We use acquire MO to synchronize-with the release MO store in pthread_spin_unlock, and thus ensure that prior critical sections happen-before this critical section. */ -#if ! ATOMIC_EXCHANGE_USES_CAS - /* Try to acquire the lock with an exchange instruction as this architecture - has such an instruction and we assume it is faster than a CAS. - The acquisition succeeds if the lock is not in an acquired state. */ if (__glibc_likely (atomic_exchange_acquire (lock, 1) == 0)) return 0; -#else - /* Try to acquire the lock with a CAS instruction as this architecture - has no exchange instruction. The acquisition succeeds if the lock is not - acquired. */ - if (__glibc_likely (atomic_compare_exchange_weak_acquire (lock, &val, 1))) - return 0; -#endif do { diff --git a/nptl/pthread_spin_trylock.c b/nptl/pthread_spin_trylock.c index f2b12f9b4fe34340c9a2e449f2652908a7ff469d..3bd870401cdb336fe05469c3944b82fa563869be 100644 --- a/nptl/pthread_spin_trylock.c +++ b/nptl/pthread_spin_trylock.c @@ -24,57 +24,8 @@ int __pthread_spin_trylock (pthread_spinlock_t *lock) { - /* For the spin try lock, we have the following possibilities: - - 1) If we assume that trylock will most likely succeed in practice: - * We just do an exchange. - - 2) If we want to bias towards cases where trylock succeeds, but don't - rule out contention: - * If exchange is not implemented by a CAS loop, and exchange is faster - than CAS, do an exchange. - * If exchange is implemented by a CAS loop, use a weak CAS and not an - exchange so we bail out after the first failed attempt to change the state. - - 3) If we expect contention to be likely: - * If CAS always brings the cache line into an exclusive state even if the - spinlock is already acquired, then load the value first with - atomic_load_relaxed and test if lock is not acquired. Then do 2). - - We assume that 2) is the common case, and that this won't be slower than - 1) in the common case. - - We use acquire MO to synchronize-with the release MO store in - pthread_spin_unlock, and thus ensure that prior critical sections - happen-before this critical section. */ -#if ! ATOMIC_EXCHANGE_USES_CAS - /* Try to acquire the lock with an exchange instruction as this architecture - has such an instruction and we assume it is faster than a CAS. - The acquisition succeeds if the lock is not in an acquired state. */ if (atomic_exchange_acquire (lock, 1) == 0) return 0; -#else - /* Try to acquire the lock with a CAS instruction as this architecture - has no exchange instruction. The acquisition succeeds if the lock is not - acquired. */ - do - { - int val = 0; - if (atomic_compare_exchange_weak_acquire (lock, &val, 1)) - return 0; - } - /* atomic_compare_exchange_weak_acquire can fail spuriously. Whereas - C++11 and C11 make it clear that trylock operations can fail spuriously, - POSIX does not explicitly specify this; it only specifies that failing - synchronization operations do not need to have synchronization effects - themselves, but a spurious failure is something that could contradict a - happens-before established earlier (e.g., that we need to observe that - the lock is acquired). Therefore, we emulate a strong CAS by simply - checking with a relaxed MO load that the lock is really acquired before - returning EBUSY; the additional overhead this may cause is on the slow - path. */ - while (atomic_load_relaxed (lock) == 0); -#endif return EBUSY; } diff --git a/sysdeps/aarch64/atomic-machine.h b/sysdeps/aarch64/atomic-machine.h deleted file mode 100644 index 2dc1c524e40e2e805161e6d9b1b385b85c53a5c8..0000000000000000000000000000000000000000 --- a/sysdeps/aarch64/atomic-machine.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _AARCH64_ATOMIC_MACHINE_H -#define _AARCH64_ATOMIC_MACHINE_H 1 - -#define __HAVE_64B_ATOMICS 1 -#define ATOMIC_EXCHANGE_USES_CAS 0 - -#endif diff --git a/sysdeps/alpha/atomic-machine.h b/sysdeps/alpha/atomic-machine.h deleted file mode 100644 index 7fbe5b87eebf323d38fe1349b02aa56fe199cab3..0000000000000000000000000000000000000000 --- a/sysdeps/alpha/atomic-machine.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#include <stdint.h> - -#define __HAVE_64B_ATOMICS 1 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/arc/atomic-machine.h b/sysdeps/arc/atomic-machine.h deleted file mode 100644 index 2d519e3bbfa9ce77f4a41e313b67a690569d032e..0000000000000000000000000000000000000000 --- a/sysdeps/arc/atomic-machine.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Low-level functions for atomic operations. ARC version. - Copyright (C) 2020-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _ARC_BITS_ATOMIC_H -#define _ARC_BITS_ATOMIC_H 1 - -#define __HAVE_64B_ATOMICS 0 - -/* ARC does have legacy atomic EX reg, [mem] instruction but the micro-arch - is not as optimal as LLOCK/SCOND specially for SMP. */ -#define ATOMIC_EXCHANGE_USES_CAS 1 - -#endif /* _ARC_BITS_ATOMIC_H */ diff --git a/sysdeps/arm/atomic-machine.h b/sysdeps/arm/atomic-machine.h deleted file mode 100644 index b172573ae74dc9d6c7618bfdb76f5fb0429469f8..0000000000000000000000000000000000000000 --- a/sysdeps/arm/atomic-machine.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Atomic operations. Pure ARM version. - Copyright (C) 2002-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#define __HAVE_64B_ATOMICS 0 -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/csky/atomic-machine.h b/sysdeps/csky/atomic-machine.h deleted file mode 100644 index 4a7dc63be2044990852c52500943c90c898363be..0000000000000000000000000000000000000000 --- a/sysdeps/csky/atomic-machine.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Atomic operations. C-SKY version. - Copyright (C) 2018-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef __CSKY_ATOMIC_H_ -#define __CSKY_ATOMIC_H_ - -#define __HAVE_64B_ATOMICS 0 -#define ATOMIC_EXCHANGE_USES_CAS 1 - -#endif /* atomic-machine.h */ diff --git a/sysdeps/ia64/atomic-machine.h b/sysdeps/ia64/atomic-machine.h deleted file mode 100644 index 6f31c7b2eea67b5d8766dea1c38df6eedc168ebf..0000000000000000000000000000000000000000 --- a/sysdeps/ia64/atomic-machine.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#include <ia64intrin.h> - -#define __HAVE_64B_ATOMICS 1 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 0 diff --git a/sysdeps/m68k/coldfire/atomic-machine.h b/sysdeps/m68k/coldfire/atomic-machine.h deleted file mode 100644 index 1503703ed36b825f6e9f2cb2ed1516cd80bd9947..0000000000000000000000000000000000000000 --- a/sysdeps/m68k/coldfire/atomic-machine.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _ATOMIC_MACHINE_H -#define _ATOMIC_MACHINE_H 1 - -/* If we have just non-atomic operations, we can as well make them wide. */ -#define __HAVE_64B_ATOMICS 1 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 - -#endif diff --git a/sysdeps/m68k/m680x0/m68020/atomic-machine.h b/sysdeps/m68k/m680x0/m68020/atomic-machine.h deleted file mode 100644 index d356b55c9f9082db8dde734c254e01a631201206..0000000000000000000000000000000000000000 --- a/sysdeps/m68k/m680x0/m68020/atomic-machine.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -/* GCC does not support lock-free 64-bit atomic_load/store. */ -#define __HAVE_64B_ATOMICS 0 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/microblaze/atomic-machine.h b/sysdeps/microblaze/atomic-machine.h deleted file mode 100644 index 4e7ccce21e59453f5233bdf82b22215d9a6d17b3..0000000000000000000000000000000000000000 --- a/sysdeps/microblaze/atomic-machine.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#include <sysdep.h> - -#define __HAVE_64B_ATOMICS 0 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/mips/atomic-machine.h b/sysdeps/mips/atomic-machine.h deleted file mode 100644 index 1e611c2153996d28e14611c60189f52d0919b79c..0000000000000000000000000000000000000000 --- a/sysdeps/mips/atomic-machine.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Low-level functions for atomic operations. Mips version. - Copyright (C) 2005-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _MIPS_ATOMIC_MACHINE_H -#define _MIPS_ATOMIC_MACHINE_H 1 - -#include <sgidefs.h> - -#if _MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIN32 -#define __HAVE_64B_ATOMICS 0 -#else -#define __HAVE_64B_ATOMICS 1 -#endif - -/* MIPS is an LL/SC machine. However, XLP has a direct atomic exchange - instruction which will be used by __atomic_exchange_n. */ -#ifdef _MIPS_ARCH_XLP -# define ATOMIC_EXCHANGE_USES_CAS 0 -#else -# define ATOMIC_EXCHANGE_USES_CAS 1 -#endif - -#endif /* atomic-machine.h */ diff --git a/sysdeps/or1k/atomic-machine.h b/sysdeps/or1k/atomic-machine.h deleted file mode 100644 index 90a10867b3f9cf97a0f2f521f6759a0008ef5b82..0000000000000000000000000000000000000000 --- a/sysdeps/or1k/atomic-machine.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Atomic operations. OpenRISC version. - Copyright (C) 2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef __OR1K_ATOMIC_H_ -#define __OR1K_ATOMIC_H_ - -#include <stdint.h> - -#define __HAVE_64B_ATOMICS 0 -#define ATOMIC_EXCHANGE_USES_CAS 1 - -#endif /* atomic-machine.h */ diff --git a/sysdeps/powerpc/powerpc32/atomic-machine.h b/sysdeps/powerpc/powerpc32/atomic-machine.h index 6a2aae8bdb34281144e6810924377a6a62857d15..5d1d1ca120530371daaf97d5d0c5b545b2327a78 100644 --- a/sysdeps/powerpc/powerpc32/atomic-machine.h +++ b/sysdeps/powerpc/powerpc32/atomic-machine.h @@ -33,6 +33,3 @@ #endif #define __ARCH_ACQ_INSTR "isync" - -#define __HAVE_64B_ATOMICS 0 -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/powerpc/powerpc64/atomic-machine.h b/sysdeps/powerpc/powerpc64/atomic-machine.h index 2932f889c5bc6d0fa49d5ad36875b50c27ad07e9..cdee4b84827bcb8455972302725edb3fb76a744c 100644 --- a/sysdeps/powerpc/powerpc64/atomic-machine.h +++ b/sysdeps/powerpc/powerpc64/atomic-machine.h @@ -33,6 +33,3 @@ #endif #define __ARCH_ACQ_INSTR "isync" - -#define __HAVE_64B_ATOMICS 1 -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/s390/atomic-machine.h b/sysdeps/s390/atomic-machine.h deleted file mode 100644 index 3e25dcf44126001382e3b98aa2f82d29e29f1424..0000000000000000000000000000000000000000 --- a/sysdeps/s390/atomic-machine.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#ifdef __s390x__ -# define __HAVE_64B_ATOMICS 1 -#else -# define __HAVE_64B_ATOMICS 0 -#endif - -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/sparc/atomic-machine.h b/sysdeps/sparc/atomic-machine.h index 1f0eb0a9b1171c06dc19dc21c4fe7de94adc4bce..7ea88d598b9a36735004fe03cb52e46fe4807140 100644 --- a/sysdeps/sparc/atomic-machine.h +++ b/sysdeps/sparc/atomic-machine.h @@ -19,15 +19,6 @@ #ifndef _ATOMIC_MACHINE_H #define _ATOMIC_MACHINE_H 1 -#ifdef __arch64__ -# define __HAVE_64B_ATOMICS 1 -#else -# define __HAVE_64B_ATOMICS 0 -#endif - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS __HAVE_64B_ATOMICS - #ifdef __sparc_v9__ extern void __cpu_relax (void); diff --git a/sysdeps/unix/sysv/linux/hppa/atomic-machine.h b/sysdeps/unix/sysv/linux/hppa/atomic-machine.h deleted file mode 100644 index 9c9fecbefef037e3b7e8c291e722d093b811dd69..0000000000000000000000000000000000000000 --- a/sysdeps/unix/sysv/linux/hppa/atomic-machine.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 2003-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _ATOMIC_MACHINE_H -#define _ATOMIC_MACHINE_H 1 - -#define __HAVE_64B_ATOMICS 0 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 - -#endif -/* _ATOMIC_MACHINE_H */ diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h b/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h deleted file mode 100644 index 02e54847a42bfbc93ae1e07b7e32965be644daba..0000000000000000000000000000000000000000 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2010-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _ATOMIC_MACHINE_H -#define _ATOMIC_MACHINE_H 1 - -#include <sysdep.h> - -#define __HAVE_64B_ATOMICS 0 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 - -#endif diff --git a/sysdeps/unix/sysv/linux/nios2/atomic-machine.h b/sysdeps/unix/sysv/linux/nios2/atomic-machine.h deleted file mode 100644 index 4b4b714f93f4c4b9f7f650d70d2301299a45e2f5..0000000000000000000000000000000000000000 --- a/sysdeps/unix/sysv/linux/nios2/atomic-machine.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Low-level functions for atomic operations. Nios II version. - Copyright (C) 2012-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _NIOS2_ATOMIC_MACHINE_H -#define _NIOS2_ATOMIC_MACHINE_H 1 - -#define __HAVE_64B_ATOMICS 0 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 - -#endif /* _NIOS2_ATOMIC_MACHINE_H */ diff --git a/sysdeps/unix/sysv/linux/riscv/atomic-machine.h b/sysdeps/unix/sysv/linux/riscv/atomic-machine.h index b0ebe09ce1fa4e15064dd57d83cadb8a1976f86d..90c48b301e8dad46017fe8d6497756cdd74268c8 100644 --- a/sysdeps/unix/sysv/linux/riscv/atomic-machine.h +++ b/sysdeps/unix/sysv/linux/riscv/atomic-machine.h @@ -21,9 +21,6 @@ #ifdef __riscv_atomic -# define __HAVE_64B_ATOMICS (__riscv_xlen >= 64) -# define ATOMIC_EXCHANGE_USES_CAS 0 - /* Miscellaneous. */ # define asm_amo(which, ordering, mem, value) ({ \ diff --git a/sysdeps/unix/sysv/linux/sh/atomic-machine.h b/sysdeps/unix/sysv/linux/sh/atomic-machine.h deleted file mode 100644 index 71848194daa98ad0391c029a8c7d9dba5ba5fe3d..0000000000000000000000000000000000000000 --- a/sysdeps/unix/sysv/linux/sh/atomic-machine.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Atomic operations used inside libc. Linux/SH version. - Copyright (C) 2003-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#define __HAVE_64B_ATOMICS 0 - -/* XXX Is this actually correct? */ -#define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h index 98541a2d06ff5e4aa8c789ab7405215097471971..303458d1296e4b1cd7cd654e0904ace0ffc52fae 100644 --- a/sysdeps/x86/atomic-machine.h +++ b/sysdeps/x86/atomic-machine.h @@ -21,17 +21,6 @@ #include <tls.h> /* For mach. */ -#ifdef __x86_64__ -# define __HAVE_64B_ATOMICS 1 -#else -/* Since the Pentium, i386 CPUs have supported 64-bit atomics, but the - i386 psABI supplement provides only 4-byte alignment for uint64_t - inside structs, so it is currently not possible to use 64-bit - atomics on this platform. */ -# define __HAVE_64B_ATOMICS 0 -#endif -#define ATOMIC_EXCHANGE_USES_CAS 0 - #define atomic_spin_nop() __asm ("pause") #endif /* atomic-machine.h */