[PATCH 1/1] htl: move _pthread_spin_lock, pthread_spin_{destroy, lock, init, trylock, unlock) into libc.
gfleury
gfleury@disroot.org
Wed Nov 19 08:45:15 GMT 2025
---
htl/Makefile | 7 ++--
htl/Versions | 18 +++++---
htl/pt-spin-inlines.c | 41 ++++++++++++++++---
sysdeps/htl/pthreadP.h | 11 +++++
sysdeps/i386/i686/pthread_spin_trylock.S | 2 +-
.../i386/{ => nptl}/pthread_spin_trylock.S | 0
sysdeps/mach/htl/pt-spin.c | 15 ++++---
sysdeps/mach/hurd/i386/libc.abilist | 17 ++++++++
sysdeps/mach/hurd/i386/libpthread.abilist | 11 -----
sysdeps/mach/hurd/x86_64/libc.abilist | 17 ++++++++
sysdeps/mach/hurd/x86_64/libpthread.abilist | 11 -----
sysdeps/mach/x86/machine-lock.h | 1 +
12 files changed, 106 insertions(+), 45 deletions(-)
rename sysdeps/i386/{ => nptl}/pthread_spin_trylock.S (100%)
diff --git a/htl/Makefile b/htl/Makefile
index 9f14f15c..e19d0fe5 100644
--- a/htl/Makefile
+++ b/htl/Makefile
@@ -24,10 +24,7 @@ SYSDEPS :=
LCLHDRS :=
-libpthread-routines := \
- pt-spin-inlines \
- pt-spin \
- # libpthread-routine
+libpthread-routines :=
headers := \
bits/cancelation.h \
@@ -182,6 +179,8 @@ routines := \
pt-sigstate \
pt-sigstate-destroy \
pt-sigstate-init \
+ pt-spin \
+ pt-spin-inlines \
pt-stack-alloc \
pt-startup \
pt-sysdep \
diff --git a/htl/Versions b/htl/Versions
index 0eff9fd7..0746193a 100644
--- a/htl/Versions
+++ b/htl/Versions
@@ -3,6 +3,7 @@ libc {
GLIBC_2.12 {
flockfile; ftrylockfile; funlockfile;
pthread_self;
+ _pthread_spin_lock;
__pthread_get_cleanup_stack;
__pthread_key_create;
__pthread_kill;
@@ -101,6 +102,11 @@ libc {
pthread_setschedprio;
pthread_setspecific;
pthread_sigmask;
+ pthread_spin_destroy;
+ pthread_spin_init;
+ pthread_spin_lock;
+ pthread_spin_trylock;
+ pthread_spin_unlock;
pthread_testcancel;
pthread_yield;
sem_close;
@@ -226,6 +232,7 @@ libc {
}
GLIBC_2.43 {
+ _pthread_spin_lock;
pthread_cancel;
pthread_clockjoin_np;
pthread_create;
@@ -242,6 +249,11 @@ libc {
pthread_setconcurrency;
pthread_setname_np;
pthread_setschedprio;
+ pthread_spin_destroy;
+ pthread_spin_init;
+ pthread_spin_lock;
+ pthread_spin_trylock;
+ pthread_spin_unlock;
pthread_testcancel;
pthread_timedjoin_np;
pthread_tryjoin_np;
@@ -335,12 +347,6 @@ libpthread {
GLIBC_2.12 {
pthread_atfork;
-
- pthread_spin_destroy; pthread_spin_init; pthread_spin_lock;
- pthread_spin_trylock; pthread_spin_unlock;
- __pthread_spin_destroy; __pthread_spin_init;
- __pthread_spin_lock; __pthread_spin_trylock; __pthread_spin_unlock;
- _pthread_spin_lock;
}
GLIBC_2.21 {
__libpthread_version_placeholder;
diff --git a/htl/pt-spin-inlines.c b/htl/pt-spin-inlines.c
index 6e1e218e..6bdd4ee0 100644
--- a/htl/pt-spin-inlines.c
+++ b/htl/pt-spin-inlines.c
@@ -24,10 +24,39 @@
#define __PT_SPIN_INLINE /* empty */
#include <pthread.h>
+#include <shlib-compat.h>
-/* Weak aliases for the spin lock functions. */
-weak_alias (__pthread_spin_destroy, pthread_spin_destroy);
-weak_alias (__pthread_spin_init, pthread_spin_init);
-weak_alias (__pthread_spin_trylock, pthread_spin_trylock);
-weak_alias (__pthread_spin_lock, pthread_spin_lock);
-weak_alias (__pthread_spin_unlock, pthread_spin_unlock);
+libc_hidden_def (__pthread_spin_destroy)
+versioned_symbol (libc, __pthread_spin_destroy, pthread_spin_destroy, GLIBC_2_43);
+
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_43)
+compat_symbol (libc, __pthread_spin_destroy, pthread_spin_destroy, GLIBC_2_12);
+#endif
+
+libc_hidden_def (__pthread_spin_init)
+versioned_symbol (libc, __pthread_spin_init, pthread_spin_init, GLIBC_2_43);
+
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_43)
+compat_symbol (libc, __pthread_spin_init, pthread_spin_init, GLIBC_2_12);
+#endif
+
+libc_hidden_def (__pthread_spin_trylock)
+versioned_symbol (libc, __pthread_spin_trylock, pthread_spin_trylock, GLIBC_2_43);
+
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_43)
+compat_symbol (libc, __pthread_spin_trylock, pthread_spin_trylock, GLIBC_2_12);
+#endif
+
+libc_hidden_def (__pthread_spin_lock)
+versioned_symbol (libc, __pthread_spin_lock, pthread_spin_lock, GLIBC_2_43);
+
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_43)
+compat_symbol (libc, __pthread_spin_lock, pthread_spin_lock, GLIBC_2_12);
+#endif
+
+libc_hidden_def (__pthread_spin_unlock)
+versioned_symbol (libc, __pthread_spin_unlock, pthread_spin_unlock, GLIBC_2_43);
+
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_43)
+compat_symbol (libc, __pthread_spin_unlock, pthread_spin_unlock, GLIBC_2_12);
+#endif
diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h
index 6ea1e79a..fb6a84b4 100644
--- a/sysdeps/htl/pthreadP.h
+++ b/sysdeps/htl/pthreadP.h
@@ -231,6 +231,17 @@ libc_hidden_proto (__pthread_getname_np)
int __pthread_setname_np (pthread_t __target_thread, const char *__name);
libc_hidden_proto (__pthread_setname_np)
+int __pthread_spin_destroy (pthread_spinlock_t *__lock);
+libc_hidden_proto (__pthread_spin_destroy)
+int __pthread_spin_init (pthread_spinlock_t *__lock, int __pshared);
+libc_hidden_proto (__pthread_spin_init)
+int __pthread_spin_lock (pthread_spinlock_t *__lock);
+libc_hidden_proto (__pthread_spin_lock)
+int __pthread_spin_trylock (pthread_spinlock_t *__lock);
+libc_hidden_proto (__pthread_spin_trylock)
+int __pthread_spin_unlock (pthread_spinlock_t *__lock);
+libc_hidden_proto (__pthread_spin_unlock)
+
#define __pthread_raise_internal(__sig) raise (__sig)
libc_hidden_proto (__pthread_self)
diff --git a/sysdeps/i386/i686/pthread_spin_trylock.S b/sysdeps/i386/i686/pthread_spin_trylock.S
index 49161fec..129bb239 100644
--- a/sysdeps/i386/i686/pthread_spin_trylock.S
+++ b/sysdeps/i386/i686/pthread_spin_trylock.S
@@ -16,4 +16,4 @@
<https://www.gnu.org/licenses/>. */
#define HAVE_CMOV 1
-#include <sysdeps/i386/pthread_spin_trylock.S>
+#include <sysdeps/i386/nptl/pthread_spin_trylock.S>
diff --git a/sysdeps/i386/pthread_spin_trylock.S b/sysdeps/i386/nptl/pthread_spin_trylock.S
similarity index 100%
rename from sysdeps/i386/pthread_spin_trylock.S
rename to sysdeps/i386/nptl/pthread_spin_trylock.S
diff --git a/sysdeps/mach/htl/pt-spin.c b/sysdeps/mach/htl/pt-spin.c
index ff7db552..d5713666 100644
--- a/sysdeps/mach/htl/pt-spin.c
+++ b/sysdeps/mach/htl/pt-spin.c
@@ -16,16 +16,19 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <machine-lock.h>
-
-/* In glibc. */
-extern void __spin_lock_solid (__spin_lock_t *lock);
-
+#include <lock-intern.h>
+#include <shlib-compat.h>
/* Lock the spin lock object LOCK. If the lock is held by another
thread spin until it becomes available. */
int
-_pthread_spin_lock (__spin_lock_t *lock)
+___pthread_spin_lock (__spin_lock_t *lock)
{
__spin_lock_solid (lock);
return 0;
}
+
+versioned_symbol (libc, ___pthread_spin_lock, _pthread_spin_lock, GLIBC_2_43);
+
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_43)
+compat_symbol (libc, ___pthread_spin_lock, _pthread_spin_lock, GLIBC_2_12);
+#endif
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index 6099178c..6e189b94 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -33,6 +33,7 @@ GLIBC_2.12 __pthread_key_create F
GLIBC_2.12 __pthread_kill F
GLIBC_2.12 __pthread_mutex_transfer_np F
GLIBC_2.12 __pthread_self F
+GLIBC_2.12 _pthread_spin_lock F
GLIBC_2.12 flockfile F
GLIBC_2.12 ftrylockfile F
GLIBC_2.12 funlockfile F
@@ -130,6 +131,11 @@ GLIBC_2.12 pthread_setschedparam F
GLIBC_2.12 pthread_setschedprio F
GLIBC_2.12 pthread_setspecific F
GLIBC_2.12 pthread_sigmask F
+GLIBC_2.12 pthread_spin_destroy F
+GLIBC_2.12 pthread_spin_init F
+GLIBC_2.12 pthread_spin_lock F
+GLIBC_2.12 pthread_spin_trylock F
+GLIBC_2.12 pthread_spin_unlock F
GLIBC_2.12 pthread_testcancel F
GLIBC_2.12 pthread_yield F
GLIBC_2.12 sem_close F
@@ -508,6 +514,11 @@ GLIBC_2.2.6 __printf_fp F
GLIBC_2.2.6 __profile_frequency F
GLIBC_2.2.6 __progname D 0x4
GLIBC_2.2.6 __progname_full D 0x4
+GLIBC_2.2.6 __pthread_spin_destroy F
+GLIBC_2.2.6 __pthread_spin_init F
+GLIBC_2.2.6 __pthread_spin_lock F
+GLIBC_2.2.6 __pthread_spin_trylock F
+GLIBC_2.2.6 __pthread_spin_unlock F
GLIBC_2.2.6 __pwrite64 F
GLIBC_2.2.6 __rawmemchr F
GLIBC_2.2.6 __rcmd_errstr D 0x4
@@ -2671,6 +2682,7 @@ GLIBC_2.42 uimaxabs F
GLIBC_2.42 ulabs F
GLIBC_2.42 ullabs F
GLIBC_2.43 __memset_explicit_chk F
+GLIBC_2.43 _pthread_spin_lock F
GLIBC_2.43 memalignment F
GLIBC_2.43 memset_explicit F
GLIBC_2.43 pthread_cancel F
@@ -2689,6 +2701,11 @@ GLIBC_2.43 pthread_mutex_transfer_np F
GLIBC_2.43 pthread_setconcurrency F
GLIBC_2.43 pthread_setname_np F
GLIBC_2.43 pthread_setschedprio F
+GLIBC_2.43 pthread_spin_destroy F
+GLIBC_2.43 pthread_spin_init F
+GLIBC_2.43 pthread_spin_lock F
+GLIBC_2.43 pthread_spin_trylock F
+GLIBC_2.43 pthread_spin_unlock F
GLIBC_2.43 pthread_testcancel F
GLIBC_2.43 pthread_timedjoin_np F
GLIBC_2.43 pthread_tryjoin_np F
diff --git a/sysdeps/mach/hurd/i386/libpthread.abilist b/sysdeps/mach/hurd/i386/libpthread.abilist
index 24e6bd2c..75636d84 100644
--- a/sysdeps/mach/hurd/i386/libpthread.abilist
+++ b/sysdeps/mach/hurd/i386/libpthread.abilist
@@ -1,15 +1,4 @@
-GLIBC_2.12 __pthread_spin_destroy F
-GLIBC_2.12 __pthread_spin_init F
-GLIBC_2.12 __pthread_spin_lock F
-GLIBC_2.12 __pthread_spin_trylock F
-GLIBC_2.12 __pthread_spin_unlock F
-GLIBC_2.12 _pthread_spin_lock F
GLIBC_2.12 pthread_atfork F
-GLIBC_2.12 pthread_spin_destroy F
-GLIBC_2.12 pthread_spin_init F
-GLIBC_2.12 pthread_spin_lock F
-GLIBC_2.12 pthread_spin_trylock F
-GLIBC_2.12 pthread_spin_unlock F
GLIBC_2.32 call_once F
GLIBC_2.32 cnd_broadcast F
GLIBC_2.32 cnd_destroy F
diff --git a/sysdeps/mach/hurd/x86_64/libc.abilist b/sysdeps/mach/hurd/x86_64/libc.abilist
index 1aab058a..c2045b79 100644
--- a/sysdeps/mach/hurd/x86_64/libc.abilist
+++ b/sysdeps/mach/hurd/x86_64/libc.abilist
@@ -396,6 +396,12 @@ GLIBC_2.38 __pthread_key_create F
GLIBC_2.38 __pthread_kill F
GLIBC_2.38 __pthread_mutex_transfer_np F
GLIBC_2.38 __pthread_self F
+GLIBC_2.38 __pthread_spin_destroy F
+GLIBC_2.38 __pthread_spin_init F
+GLIBC_2.38 __pthread_spin_lock F
+GLIBC_2.38 __pthread_spin_trylock F
+GLIBC_2.38 __pthread_spin_unlock F
+GLIBC_2.38 _pthread_spin_lock F
GLIBC_2.38 __ptsname_r_chk F
GLIBC_2.38 __pwrite64 F
GLIBC_2.38 __rawmemchr F
@@ -1621,6 +1627,11 @@ GLIBC_2.38 pthread_setschedparam F
GLIBC_2.38 pthread_setschedprio F
GLIBC_2.38 pthread_setspecific F
GLIBC_2.38 pthread_sigmask F
+GLIBC_2.38 pthread_spin_destroy F
+GLIBC_2.38 pthread_spin_init F
+GLIBC_2.38 pthread_spin_lock F
+GLIBC_2.38 pthread_spin_trylock F
+GLIBC_2.38 pthread_spin_unlock F
GLIBC_2.38 pthread_testcancel F
GLIBC_2.38 pthread_timedjoin_np F
GLIBC_2.38 pthread_tryjoin_np F
@@ -2349,6 +2360,7 @@ GLIBC_2.42 uimaxabs F
GLIBC_2.42 ulabs F
GLIBC_2.42 ullabs F
GLIBC_2.43 __memset_explicit_chk F
+GLIBC_2.43 _pthread_spin_lock F
GLIBC_2.43 memalignment F
GLIBC_2.43 memset_explicit F
GLIBC_2.43 pthread_cancel F
@@ -2367,6 +2379,11 @@ GLIBC_2.43 pthread_mutex_transfer_np F
GLIBC_2.43 pthread_setconcurrency F
GLIBC_2.43 pthread_setname_np F
GLIBC_2.43 pthread_setschedprio F
+GLIBC_2.43 pthread_spin_destroy F
+GLIBC_2.43 pthread_spin_init F
+GLIBC_2.43 pthread_spin_lock F
+GLIBC_2.43 pthread_spin_trylock F
+GLIBC_2.43 pthread_spin_unlock F
GLIBC_2.43 pthread_testcancel F
GLIBC_2.43 pthread_timedjoin_np F
GLIBC_2.43 pthread_tryjoin_np F
diff --git a/sysdeps/mach/hurd/x86_64/libpthread.abilist b/sysdeps/mach/hurd/x86_64/libpthread.abilist
index 57d79648..b4f2a962 100644
--- a/sysdeps/mach/hurd/x86_64/libpthread.abilist
+++ b/sysdeps/mach/hurd/x86_64/libpthread.abilist
@@ -1,9 +1,3 @@
-GLIBC_2.38 __pthread_spin_destroy F
-GLIBC_2.38 __pthread_spin_init F
-GLIBC_2.38 __pthread_spin_lock F
-GLIBC_2.38 __pthread_spin_trylock F
-GLIBC_2.38 __pthread_spin_unlock F
-GLIBC_2.38 _pthread_spin_lock F
GLIBC_2.38 call_once F
GLIBC_2.38 cnd_broadcast F
GLIBC_2.38 cnd_destroy F
@@ -17,11 +11,6 @@ GLIBC_2.38 mtx_lock F
GLIBC_2.38 mtx_timedlock F
GLIBC_2.38 mtx_trylock F
GLIBC_2.38 mtx_unlock F
-GLIBC_2.38 pthread_spin_destroy F
-GLIBC_2.38 pthread_spin_init F
-GLIBC_2.38 pthread_spin_lock F
-GLIBC_2.38 pthread_spin_trylock F
-GLIBC_2.38 pthread_spin_unlock F
GLIBC_2.38 thrd_create F
GLIBC_2.38 thrd_detach F
GLIBC_2.38 thrd_exit F
diff --git a/sysdeps/mach/x86/machine-lock.h b/sysdeps/mach/x86/machine-lock.h
index f27fc2f8..45f87f9b 100644
--- a/sysdeps/mach/x86/machine-lock.h
+++ b/sysdeps/mach/x86/machine-lock.h
@@ -51,6 +51,7 @@ __spin_unlock (__spin_lock_t *__lock)
extern int __spin_try_lock (__spin_lock_t *__lock);
+
#if defined __USE_EXTERN_INLINES && defined _LIBC
_EXTERN_INLINE int
__spin_try_lock (__spin_lock_t *__lock)
--
2.52.0
More information about the Libc-alpha
mailing list