From patchwork Thu Nov 20 08:56:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gfleury X-Patchwork-Id: 124798 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3B895385AC22 for ; Thu, 20 Nov 2025 08:57:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B895385AC22 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (2048-bit key, secure) header.d=disroot.org header.i=@disroot.org header.a=rsa-sha256 header.s=mail header.b=OxTBczOJ X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) by sourceware.org (Postfix) with ESMTPS id 6B7823858C24 for ; Thu, 20 Nov 2025 08:57:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B7823858C24 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=disroot.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6B7823858C24 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763629032; cv=none; b=PJI7Iwb+x/2f05QiJIqQMQOoS5tveawYqbOiTq60sY0pHupwVbOe6YbSe5o/X5uyEZEflgslqQw3/J4z6yI1I8CfJ6Wib5zhtDMF985XCiIt8a+O1gAllO1erL+JOjVtcFx0PTlgo04RKP2Z87OSm1iTR9+K+1UqGvSrCvFKnBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763629032; c=relaxed/simple; bh=B9RxQeAlR7tap4LBebejzTPjgV6U9MEUbLr6lAIy/9g=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kkv/midvUrBsDgqlpWlUEFMtjhnljCsfJfEUXAvw8fijBhlRFr7nudmmOjoJO+9EkhG9iZxO66tXBrTNkwVzNaW9MwCim6OvQygflHZdZO8sT0vsYjbs4n3P/g3Ru9sEygw8P+f228ifVDhWO845PhkTbM1sNWwM3Vo/0+yfHEc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B7823858C24 Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 416A325B4D; Thu, 20 Nov 2025 09:57:10 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id fvSJ7Nwf0qS2; Thu, 20 Nov 2025 09:57:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1763629027; bh=B9RxQeAlR7tap4LBebejzTPjgV6U9MEUbLr6lAIy/9g=; h=From:To:Cc:Subject:Date; b=OxTBczOJq+FoGWD6+Vq+OA/agkW8gRT3XZ5kDTY8l8k9sfjTsuSFo+E5mi1GK9dXJ 5h5pLtyiEwF6hJ4DYQclEX1mlGLkg1JVmJf47g3pDI6yy+ymY/y9lqxJlYL0FmYA9b QPEXWXcrKZPLoHBKcptZkw6YuRBd6dd3wHDfB0w9P7D9ZaTuX5cpzEGyuUuJZ3wIeX J5NWyXinHXRoClktRJBqncLgjnQzBwr/H3UE6+/Ef6NdtkBy4fsJdkan2bXHs0dtsq K+yGfrfZ7ggojI/JmONURnwTsvDrl4TKzV2YGHKi9SJX0JoWsH3EeDWOi3V/nWyb7T 2RIuAm0K9RWBg== From: gfleury To: libc-alpha@sourceware.org Cc: gfleury Subject: [PATCH v2] htl: move pthread_spin_{destroy, lock, init, trylock, unlock) and remove _pthread_spin_lock, into libc. Date: Thu, 20 Nov 2025 10:56:47 +0200 Message-ID: <20251120085647.326643-1-gfleury@disroot.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_HOSTKARMA_W, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org --- htl/Makefile | 7 +--- htl/Versions | 16 +++++--- htl/pt-spin-inlines.c | 41 ++++++++++++++++--- sysdeps/htl/Versions | 4 -- 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 | 31 -------------- sysdeps/mach/hurd/i386/libc.abilist | 10 +++++ sysdeps/mach/hurd/i386/libpthread.abilist | 11 ----- sysdeps/mach/hurd/x86_64/libc.abilist | 10 +++++ sysdeps/mach/hurd/x86_64/libpthread.abilist | 11 ----- 12 files changed, 79 insertions(+), 75 deletions(-) rename sysdeps/i386/{ => nptl}/pthread_spin_trylock.S (100%) delete mode 100644 sysdeps/mach/htl/pt-spin.c diff --git a/htl/Makefile b/htl/Makefile index 9f14f15c..072db7ee 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 \ @@ -36,7 +33,6 @@ headers := \ bits/pthreadtypes-arch.h \ bits/pthreadtypes.h \ bits/semaphore.h \ - bits/spin-lock-inline.h \ bits/thread-shared-types.h \ bits/types/__pthread_key.h \ bits/types/__pthread_spinlock_t.h \ @@ -182,6 +178,7 @@ routines := \ pt-sigstate \ pt-sigstate-destroy \ pt-sigstate-init \ + pt-spin-inlines \ pt-stack-alloc \ pt-startup \ pt-sysdep \ diff --git a/htl/Versions b/htl/Versions index 0eff9fd7..25b79f08 100644 --- a/htl/Versions +++ b/htl/Versions @@ -101,6 +101,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; @@ -242,6 +247,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 +345,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 +#include -/* 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/Versions b/sysdeps/htl/Versions index 7b5450d2..e3c9a593 100644 --- a/sysdeps/htl/Versions +++ b/sysdeps/htl/Versions @@ -4,10 +4,6 @@ libc { __vm_deallocate; __mach_port_insert_right; __mach_reply_port; __mig_init; __vm_allocate; __mach_port_allocate; - # functions used in inline functions or macros - __pthread_spin_destroy; __pthread_spin_init; __pthread_spin_lock; - _pthread_spin_lock; __pthread_spin_trylock; __pthread_spin_unlock; - # p* pthread_spin_destroy; pthread_spin_init; pthread_spin_lock; pthread_spin_trylock; pthread_spin_unlock; 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 @@ . */ #define HAVE_CMOV 1 -#include +#include 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 deleted file mode 100644 index ff7db552..00000000 --- a/sysdeps/mach/htl/pt-spin.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Spin locks. Mach version. - Copyright (C) 2002-2025 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 - . */ - -#include - -/* In glibc. */ -extern void __spin_lock_solid (__spin_lock_t *lock); - -/* 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) -{ - __spin_lock_solid (lock); - return 0; -} diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist index 6099178c..281f0d00 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -130,6 +130,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 @@ -2689,6 +2694,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..ff15cff2 100644 --- a/sysdeps/mach/hurd/x86_64/libc.abilist +++ b/sysdeps/mach/hurd/x86_64/libc.abilist @@ -1621,6 +1621,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 @@ -2367,6 +2372,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