From f851a7434696b70ce7c266ade1de2469619e6f52 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 11 Nov 2025 22:32:39 +0100 Subject: [PATCH] hurd: Drop remnants of cthreads These are not used in GNU/Hurd since very long now. --- .../strcoll-inputs/filelist#en_US.UTF-8 | 1 - htl/Makefile | 1 - htl/Versions | 16 --- htl/cthreads-compat.c | 102 ------------------ htl/libpthread_syms.a | 13 --- htl/lockfile.c | 26 ++--- htl/pt-initialize.c | 7 +- hurd/Versions | 5 +- mach/Makefile | 2 +- mach/Versions | 3 +- mach/mutex-solid.c | 35 ------ sysdeps/htl/pthread-functions.h | 4 - sysdeps/htl/pthreadP.h | 9 -- sysdeps/mach/hurd/Makefile | 4 - sysdeps/mach/hurd/cthreads.c | 48 --------- sysdeps/mach/hurd/i386/libc.abilist | 5 - sysdeps/mach/hurd/i386/libpthread.abilist | 10 -- sysdeps/mach/hurd/x86_64/libc.abilist | 5 - sysdeps/mach/hurd/x86_64/libpthread.abilist | 10 -- 19 files changed, 17 insertions(+), 289 deletions(-) delete mode 100644 htl/cthreads-compat.c delete mode 100644 mach/mutex-solid.c delete mode 100644 sysdeps/mach/hurd/cthreads.c diff --git a/benchtests/strcoll-inputs/filelist#en_US.UTF-8 b/benchtests/strcoll-inputs/filelist#en_US.UTF-8 index 0d8f1c722ba..e02df872dc2 100644 --- a/benchtests/strcoll-inputs/filelist#en_US.UTF-8 +++ b/benchtests/strcoll-inputs/filelist#en_US.UTF-8 @@ -11696,7 +11696,6 @@ spin-lock.h spin-lock.c mig-dealloc.c errsystems.awk -mutex-solid.c Machrules lock-intern.h errorlib.h diff --git a/htl/Makefile b/htl/Makefile index 979f2904645..15cff60d314 100644 --- a/htl/Makefile +++ b/htl/Makefile @@ -35,7 +35,6 @@ libpthread-routines := \ pt-getname-np \ pt-setname-np \ cancellation \ - cthreads-compat \ herrno \ $(SYSDEPS) \ # libpthread-routine diff --git a/htl/Versions b/htl/Versions index f5ea540def7..b56b185a109 100644 --- a/htl/Versions +++ b/htl/Versions @@ -317,17 +317,6 @@ libpthread { __errno_location; __h_errno_location; } GLIBC_2.12 { - cthread_detach; - cthread_fork; - cthread_keycreate; - cthread_getspecific; - cthread_setspecific; - __mutex_lock_solid; - __mutex_unlock_solid; - _cthreads_flockfile; - _cthreads_ftrylockfile; - _cthreads_funlockfile; - flockfile; ftrylockfile; funlockfile; pthread_atfork; @@ -362,12 +351,7 @@ libpthread { GLIBC_PRIVATE { __pthread_initialize_minimal; - __cthread_detach; - __cthread_fork; __pthread_create; - __cthread_keycreate; - __cthread_getspecific; - __cthread_setspecific; __pthread_enable_asynccancel; __pthread_disable_asynccancel; } diff --git a/htl/cthreads-compat.c b/htl/cthreads-compat.c deleted file mode 100644 index d2bcf53986b..00000000000 --- a/htl/cthreads-compat.c +++ /dev/null @@ -1,102 +0,0 @@ -/* Compatibility routines for cthreads. - Copyright (C) 2000-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 -#include - -#define CTHREAD_KEY_INVALID (__cthread_key_t) -1 - -void -__cthread_detach (__cthread_t thread) -{ - int err; - pthread_t pthread = (pthread_t) (uintptr_t) thread; - - err = __pthread_detach (pthread); - assert_perror (err); -} -weak_alias (__cthread_detach, cthread_detach) - -__cthread_t -__cthread_fork (__cthread_fn_t func, void *arg) -{ - pthread_t thread; - int err; - - err = __pthread_create (&thread, NULL, func, arg); - assert_perror (err); - - return (__cthread_t) (uintptr_t) thread; -} -weak_alias (__cthread_fork, cthread_fork) - -int -__cthread_keycreate (__cthread_key_t *key) -{ - error_t err; - - err = __pthread_key_create (key, 0); - if (err) - { - errno = err; - *key = CTHREAD_KEY_INVALID; - err = -1; - } - - return err; -} -weak_alias (__cthread_keycreate, cthread_keycreate) - -int -__cthread_getspecific (__cthread_key_t key, void **val) -{ - *val = __pthread_getspecific (key); - return 0; -} -weak_alias (__cthread_getspecific, cthread_getspecific) - -int -__cthread_setspecific (__cthread_key_t key, void *val) -{ - error_t err; - - err = __pthread_setspecific (key, (const void *) val); - if (err) - { - errno = err; - err = -1; - } - - return err; -} -weak_alias (__cthread_setspecific, cthread_setspecific) - -void -__mutex_lock_solid (void *lock) -{ - __pthread_mutex_lock (lock); -} - -void -__mutex_unlock_solid (void *lock) -{ - if (__pthread_spin_trylock (lock) != 0) - /* Somebody already got the lock, that one will manage waking up others */ - return; - __pthread_mutex_unlock (lock); -} diff --git a/htl/libpthread_syms.a b/htl/libpthread_syms.a index b299edd4de1..dfce4a7a210 100644 --- a/htl/libpthread_syms.a +++ b/htl/libpthread_syms.a @@ -2,19 +2,6 @@ is to start threading. */ EXTERN(__pthread_initialize_minimal) -/* Weak references in glibc that must be filled if glibc is to be - thread safe. */ -EXTERN(cthread_detach) -EXTERN(cthread_fork) -EXTERN(cthread_keycreate) -EXTERN(cthread_getspecific) -EXTERN(cthread_setspecific) -EXTERN(__mutex_lock_solid) -EXTERN(__mutex_unlock_solid) -/* For libio stream locking. */ -EXTERN(_cthreads_flockfile) -EXTERN(_cthreads_funlockfile) -EXTERN(_cthreads_ftrylockfile) /* To create the sigthread and get its stack layout on fork */ EXTERN(pthread_create) EXTERN(pthread_detach) diff --git a/htl/lockfile.c b/htl/lockfile.c index 7cc2c26354e..b76a59a17bd 100644 --- a/htl/lockfile.c +++ b/htl/lockfile.c @@ -19,41 +19,35 @@ #include /* Must come before ! */ #include +#undef _IO_flockfile +#undef _IO_funlockfile +#undef _IO_ftrylockfile + void -_cthreads_flockfile (FILE *fp) +_IO_flockfile (FILE *fp) { _IO_lock_lock (*fp->_lock); } void -_cthreads_funlockfile (FILE *fp) +_IO_funlockfile (FILE *fp) { _IO_lock_unlock (*fp->_lock); } int -_cthreads_ftrylockfile (FILE *fp) +_IO_ftrylockfile (FILE *fp) { return __libc_lock_trylock_recursive (*fp->_lock); } -#undef _IO_flockfile -#undef _IO_funlockfile -#undef _IO_ftrylockfile #undef flockfile #undef funlockfile #undef ftrylockfile -void _IO_flockfile (FILE *) - __attribute__ ((alias ("_cthreads_flockfile"))); -void _IO_funlockfile (FILE *) - __attribute__ ((alias ("_cthreads_funlockfile"))); -int _IO_ftrylockfile (FILE *) - __attribute__ ((alias ("_cthreads_ftrylockfile"))); - void flockfile (FILE *) - __attribute__ ((weak, alias ("_cthreads_flockfile"))); + __attribute__ ((weak, alias ("_IO_flockfile"))); void funlockfile (FILE *) - __attribute__ ((weak, alias ("_cthreads_funlockfile"))); + __attribute__ ((weak, alias ("_IO_funlockfile"))); int ftrylockfile (FILE *) - __attribute__ ((weak, alias ("_cthreads_ftrylockfile"))); + __attribute__ ((weak, alias ("_IO_ftrylockfile"))); diff --git a/htl/pt-initialize.c b/htl/pt-initialize.c index a4e49edfa62..86fe66fb3ae 100644 --- a/htl/pt-initialize.c +++ b/htl/pt-initialize.c @@ -21,15 +21,16 @@ #include #include +#include #include #include #if IS_IN (libpthread) static const struct pthread_functions pthread_functions = { - .ptr__IO_flockfile = _cthreads_flockfile, - .ptr__IO_funlockfile = _cthreads_funlockfile, - .ptr__IO_ftrylockfile = _cthreads_ftrylockfile, + .ptr__IO_flockfile = _IO_flockfile, + .ptr__IO_funlockfile = _IO_funlockfile, + .ptr__IO_ftrylockfile = _IO_ftrylockfile, }; #endif /* IS_IN (libpthread) */ diff --git a/hurd/Versions b/hurd/Versions index 439e8abf32a..c1e60385426 100644 --- a/hurd/Versions +++ b/hurd/Versions @@ -140,11 +140,8 @@ libc { HURD_CTHREADS_0.3 { # weak refs to libthreads functions that libc calls iff libthreads in use - __cthread_fork; __pthread_create; __cthread_detach; __pthread_detach; + __pthread_create; __pthread_detach; __pthread_getattr_np; __pthread_attr_getstack; - - # cthreads functions with stubs in libc - __cthread_keycreate; __cthread_getspecific; __cthread_setspecific; } GLIBC_PRIVATE { diff --git a/mach/Makefile b/mach/Makefile index 38264c7af53..f40a400657b 100644 --- a/mach/Makefile +++ b/mach/Makefile @@ -22,7 +22,7 @@ include ../Makeconfig headers = mach_init.h mach.h mach_error.h mach-shortcuts.h mach/mach_traps.h \ $(interface-headers) mach/mach.h mach/mig_support.h mach/error.h \ $(lock-headers) machine-sp.h bits/mach/param.h -lock = spin-solid spin-lock mutex-init mutex-solid +lock = spin-solid spin-lock mutex-init lock-headers = lock-intern.h spin-lock.h routines = $(mach-syscalls) $(mach-shortcuts) \ mach_init mig_strncpy mig_strlen mig_memcpy msg \ diff --git a/mach/Versions b/mach/Versions index 72e9d557db8..468913cf8f7 100644 --- a/mach/Versions +++ b/mach/Versions @@ -63,8 +63,7 @@ libc { } HURD_CTHREADS_0.3 { - __mutex_init; __mutex_lock; __mutex_lock_solid; __mutex_trylock; - __mutex_unlock; __mutex_unlock_solid; + __mutex_init; __mutex_lock; __mutex_trylock; __mutex_unlock; __spin_lock; __spin_lock_init; __spin_lock_solid; __spin_try_lock; __spin_unlock; } diff --git a/mach/mutex-solid.c b/mach/mutex-solid.c deleted file mode 100644 index 1af99415558..00000000000 --- a/mach/mutex-solid.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Stub versions of mutex_lock_solid/mutex_unlock_solid for no -lthreads. - Copyright (C) 1995-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 - -/* If pthread is linked in, it will define these functions itself to do - real pthread mutex locks. This file will only be linked in when - pthread is not used, and `mutexes' are in fact just spin locks (and - some unused storage). */ - -void -__mutex_lock_solid (void *lock) -{ - __spin_lock_solid (lock); -} - -void -__mutex_unlock_solid (void *lock) -{ -} diff --git a/sysdeps/htl/pthread-functions.h b/sysdeps/htl/pthread-functions.h index 1fde0aeaa33..2b1feb4e042 100644 --- a/sysdeps/htl/pthread-functions.h +++ b/sysdeps/htl/pthread-functions.h @@ -21,10 +21,6 @@ #include -void _cthreads_flockfile (FILE *); -void _cthreads_funlockfile (FILE *); -int _cthreads_ftrylockfile (FILE *); - /* Data type shared with libc. The libc uses it to pass on calls to the thread functions. Wine pokes directly into this structure, so if possible avoid breaking it and append new hooks to the end. */ diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h index 9273a5885f6..8ea60949ecb 100644 --- a/sysdeps/htl/pthreadP.h +++ b/sysdeps/htl/pthreadP.h @@ -169,16 +169,10 @@ libc_hidden_proto (__pthread_setcanceltype); extern int __pthread_sigmask (int, const sigset_t *, sigset_t *); libc_hidden_proto (__pthread_sigmask); -typedef struct __cthread *__cthread_t; -typedef int __cthread_key_t; -typedef void * (*__cthread_fn_t)(void *__arg); - -__cthread_t __cthread_fork (__cthread_fn_t, void *); int __pthread_create (pthread_t *newthread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); -void __cthread_detach (__cthread_t); int __pthread_detach (pthread_t __threadp); libc_hidden_proto (__pthread_detach) void __pthread_exit (void *value) __attribute__ ((__noreturn__)); @@ -194,9 +188,6 @@ int __pthread_clockjoin_np (pthread_t __th, void **__thread_return, clockid_t __clockid, const struct timespec *__abstime); libc_hidden_proto (__pthread_clockjoin_np) -int __cthread_keycreate (__cthread_key_t *); -int __cthread_getspecific (__cthread_key_t, void **); -int __cthread_setspecific (__cthread_key_t, void *); int __pthread_key_create (pthread_key_t *key, void (*destr) (void *)); libc_hidden_proto (__pthread_key_create) void *__pthread_getspecific (pthread_key_t key); diff --git a/sysdeps/mach/hurd/Makefile b/sysdeps/mach/hurd/Makefile index 2149f6343ef..f1d688a6d33 100644 --- a/sysdeps/mach/hurd/Makefile +++ b/sysdeps/mach/hurd/Makefile @@ -199,10 +199,6 @@ $(objpfx)rcrt0.o: $(objpfx)static-start.o $(objpfx)abi-note.o $(objpfx)init.o endif -ifeq (hurd, $(subdir)) -sysdep_routines += cthreads -endif - ifeq (elf, $(subdir)) sysdep-dl-routines += dl-tls-initialized endif diff --git a/sysdeps/mach/hurd/cthreads.c b/sysdeps/mach/hurd/cthreads.c deleted file mode 100644 index 70af7971bd9..00000000000 --- a/sysdeps/mach/hurd/cthreads.c +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 1997-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 -#include -#include -#include -#include - -/* Placeholder for key creation routine from Hurd cthreads library. */ -int -weak_function -__cthread_keycreate (__cthread_key_t *key) -{ - *key = -1; - return __hurd_fail (ENOSYS); -} - -/* Placeholder for key retrieval routine from Hurd cthreads library. */ -int -weak_function -__cthread_getspecific (__cthread_key_t key, void **pval) -{ - *pval = NULL; - return __hurd_fail (ENOSYS); -} - -/* Placeholder for key setting routine from Hurd cthreads library. */ -int -weak_function -__cthread_setspecific (__cthread_key_t key, void *val) -{ - return __hurd_fail (ENOSYS); -} diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist index a19d3a44a21..e5bd47ac397 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -2748,15 +2748,10 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F -HURD_CTHREADS_0.3 __cthread_getspecific F -HURD_CTHREADS_0.3 __cthread_keycreate F -HURD_CTHREADS_0.3 __cthread_setspecific F HURD_CTHREADS_0.3 __mutex_init F HURD_CTHREADS_0.3 __mutex_lock F -HURD_CTHREADS_0.3 __mutex_lock_solid F HURD_CTHREADS_0.3 __mutex_trylock F HURD_CTHREADS_0.3 __mutex_unlock F -HURD_CTHREADS_0.3 __mutex_unlock_solid F HURD_CTHREADS_0.3 __pthread_detach F HURD_CTHREADS_0.3 __pthread_getattr_np F HURD_CTHREADS_0.3 __spin_lock F diff --git a/sysdeps/mach/hurd/i386/libpthread.abilist b/sysdeps/mach/hurd/i386/libpthread.abilist index a05cacf93f9..b9fd3dd489d 100644 --- a/sysdeps/mach/hurd/i386/libpthread.abilist +++ b/sysdeps/mach/hurd/i386/libpthread.abilist @@ -1,19 +1,9 @@ -GLIBC_2.12 __mutex_lock_solid F -GLIBC_2.12 __mutex_unlock_solid 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 _cthreads_flockfile F -GLIBC_2.12 _cthreads_ftrylockfile F -GLIBC_2.12 _cthreads_funlockfile F GLIBC_2.12 _pthread_spin_lock F -GLIBC_2.12 cthread_detach F -GLIBC_2.12 cthread_fork F -GLIBC_2.12 cthread_getspecific F -GLIBC_2.12 cthread_keycreate F -GLIBC_2.12 cthread_setspecific F GLIBC_2.12 flockfile F GLIBC_2.12 ftrylockfile F GLIBC_2.12 funlockfile F diff --git a/sysdeps/mach/hurd/x86_64/libc.abilist b/sysdeps/mach/hurd/x86_64/libc.abilist index 863312aa94c..5fb477342e9 100644 --- a/sysdeps/mach/hurd/x86_64/libc.abilist +++ b/sysdeps/mach/hurd/x86_64/libc.abilist @@ -2373,15 +2373,10 @@ GLIBC_2.43 sem_trywait F GLIBC_2.43 sem_unlink F GLIBC_2.43 sem_wait F GLIBC_2.43 umaxabs F -HURD_CTHREADS_0.3 __cthread_getspecific F -HURD_CTHREADS_0.3 __cthread_keycreate F -HURD_CTHREADS_0.3 __cthread_setspecific F HURD_CTHREADS_0.3 __mutex_init F HURD_CTHREADS_0.3 __mutex_lock F -HURD_CTHREADS_0.3 __mutex_lock_solid F HURD_CTHREADS_0.3 __mutex_trylock F HURD_CTHREADS_0.3 __mutex_unlock F -HURD_CTHREADS_0.3 __mutex_unlock_solid F HURD_CTHREADS_0.3 __pthread_detach F HURD_CTHREADS_0.3 __pthread_getattr_np F HURD_CTHREADS_0.3 __spin_lock F diff --git a/sysdeps/mach/hurd/x86_64/libpthread.abilist b/sysdeps/mach/hurd/x86_64/libpthread.abilist index 0b1dcf1e8a2..e72dca501b6 100644 --- a/sysdeps/mach/hurd/x86_64/libpthread.abilist +++ b/sysdeps/mach/hurd/x86_64/libpthread.abilist @@ -3,16 +3,11 @@ GLIBC_2.38 _IO_ftrylockfile F GLIBC_2.38 _IO_funlockfile F GLIBC_2.38 __errno_location F GLIBC_2.38 __h_errno_location F -GLIBC_2.38 __mutex_lock_solid F -GLIBC_2.38 __mutex_unlock_solid 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 _cthreads_flockfile F -GLIBC_2.38 _cthreads_ftrylockfile F -GLIBC_2.38 _cthreads_funlockfile F GLIBC_2.38 _pthread_spin_lock F GLIBC_2.38 call_once F GLIBC_2.38 cnd_broadcast F @@ -21,11 +16,6 @@ GLIBC_2.38 cnd_init F GLIBC_2.38 cnd_signal F GLIBC_2.38 cnd_timedwait F GLIBC_2.38 cnd_wait F -GLIBC_2.38 cthread_detach F -GLIBC_2.38 cthread_fork F -GLIBC_2.38 cthread_getspecific F -GLIBC_2.38 cthread_keycreate F -GLIBC_2.38 cthread_setspecific F GLIBC_2.38 flockfile F GLIBC_2.38 ftrylockfile F GLIBC_2.38 funlockfile F -- 2.47.3