Commit Graph

47 Commits

Author SHA1 Message Date
gfleury
7f045c0b48 htl: move pthread_attr_init into libc.
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19 01:37:35 +01:00
gfleury
1a1cedd635 htl: move pthread_attr_setguardsize into libc.
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19 01:37:35 +01:00
gfleury
f26b272a75 htl: move pthread_attr_setschedparam into libc.
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19 01:37:35 +01:00
gfleury
32aa498ceb htl: move pthread_attr_setscope into libc.
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19 01:37:35 +01:00
gfleury
4a8b7d7e62 htl: move pthread_attr_setstackaddr into libc.
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19 01:37:35 +01:00
gfleury
d69a010e7b htl: move pthread_attr_setstacksize into libc.
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19 01:37:35 +01:00
gfleury
330c1fad5b htl: move pthread_attr_getstack into libc.
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19 01:37:35 +01:00
gfleury
1428ae39e8 htl: move pthread_attr_getstackaddr into libc.
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19 01:37:35 +01:00
gfleury
993440a260 htl move pthread_attr_getstacksize into libc.
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19 01:34:34 +01:00
gfleury
4bcda927fe htl move pthread_attr_getscope into libc.
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19 01:19:00 +01:00
gfleury
6caf24c972 htl move pthread_attr_getguardsize into libc.
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19 01:18:59 +01:00
gfleury
f55cf584ff htl: move __pthread_default_attr into libc
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19 01:08:27 +01:00
gfleury
736befab6c htl: move pthread_attr_destroy into libc.
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19 01:08:14 +01:00
Samuel Thibault
8dc3f4f8ad hurd: Fix missing pthread_ compat symbol in libc
5476f8cd2e ("htl: move pthread_self info libc.") and
9dfa256216 ("htl: move pthread_equal into libc") to
1dc0bc8f07 ("htl: move pthread_attr_setdetachstate into libc")
moved some pthread_ symbols from libpthread.so to libc.so, but missed
adding the compat version like 5476f8cd2e ("htl: move pthread_self
info libc.") did: libc already had these symbols as forwards,
but versioned GLIBC_2.21, while the symbols in libpthread.so were
versioned GLIBC_2.12.

To fix running executables built before this, we thus have to add the
GLIBC_2.12 version, otherwise execution fails with e.g.

/usr/lib/i386-gnu/libglib-2.0.so: symbol lookup error: /usr/lib/i386-gnu/libglib-2.0.so: undefined symbol: pthread_attr_setinheritsched, version GLIBC_2.12
2024-08-01 23:58:51 +02:00
Samuel Thibault
0e75c4a463 hurd: Fix pthread_self() without libpthread
5476f8cd2e ("htl: move pthread_self info libc.") moved the htl
pthread_self() function from libpthread to libc, replacing the previous libc
stub that just returns 0. And 53da64d1cf ("htl: Initialize ___pthread_self
early") added initialization code which is needed before being able to
call pthread_self. It is currently in libpthread, and thus never called
before programs can call pthread_self from libc, which then segfaults
when accessing _pthread_self()->thread.

This moves the initialization to libc itself, as initialized variables, so
pthread_self can always be called fine.
2024-07-17 14:14:21 +02:00
Flavio Cruz
2dcc908538 Add pthread_getname_np and pthread_setname_np for Hurd
We use thread_get_name and thread_set_name to get and set the thread
name, so nothing is stored in the thread structure since these functions
are supposed to be called sparingly.

One notable difference with Linux is that the thread name is up to 32
chars, whereas Linux's is 16.

Also added a mach_RPC_CHECK to check for the existing of gnumach RPCs.
2024-07-16 09:21:52 +02:00
Guy-Fleury Iteriteka
1dc0bc8f07 htl: move pthread_attr_setdetachstate into libc
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org>
Message-Id: <20230716084414.107245-11-gfleury@disroot.org>
2023-08-24 01:57:22 +02:00
Guy-Fleury Iteriteka
92a6c26470 htl: move pthread_attr_getdetachstate into libc
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org>
Message-Id: <20230716084414.107245-10-gfleury@disroot.org>
2023-08-24 01:57:17 +02:00
Guy-Fleury Iteriteka
c2c9feebdc htl: move pthread_attr_setschedpolicy into libc
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org>
Message-Id: <20230716084414.107245-9-gfleury@disroot.org>
2023-08-24 01:57:16 +02:00
Guy-Fleury Iteriteka
0f3a39072b htl: move pthread_attr_getschedpolicy into libc
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org>
Message-Id: <20230716084414.107245-8-gfleury@disroot.org>
2023-08-24 01:57:14 +02:00
Guy-Fleury Iteriteka
fb2d92a5b3 htl: move pthread_attr_setinheritsched into libc
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org>
Message-Id: <20230716084414.107245-7-gfleury@disroot.org>
2023-08-24 01:57:13 +02:00
Guy-Fleury Iteriteka
62cf5d2bb3 htl: move pthread_attr_getinheritsched into libc
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org>
Message-Id: <20230716084414.107245-6-gfleury@disroot.org>
2023-08-24 01:57:11 +02:00
Guy-Fleury Iteriteka
79de1a0ca2 htl: move pthread_attr_getschedparam into libc
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org>
Message-Id: <20230716084414.107245-5-gfleury@disroot.org>
2023-08-24 01:57:10 +02:00
Guy-Fleury Iteriteka
3caa6362d0 htl: move pthread_setschedparam into libc
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org>
Message-Id: <20230716084414.107245-4-gfleury@disroot.org>
2023-08-24 01:57:08 +02:00
Guy-Fleury Iteriteka
a1a942fb5f htl: move pthread_getschedparam into libc
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org>
Message-Id: <20230716084414.107245-3-gfleury@disroot.org>
2023-08-24 01:57:04 +02:00
Guy-Fleury Iteriteka
9dfa256216 htl: move pthread_equal into libc
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org>
Message-Id: <20230716084414.107245-2-gfleury@disroot.org>
2023-08-24 01:56:57 +02:00
Guy-Fleury Iteriteka
5476f8cd2e htl: move pthread_self info libc.
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org>
Message-Id: <20230318095826.1125734-4-gfleury@disroot.org>
2023-04-05 01:26:36 +02:00
Guy-Fleury Iteriteka
f987e9b7a3 htl: move ___pthread_self into libc.
sysdeps/mach/hurd/htl/pt-pthread_self.c: New file.
htl/Makefile: .. Add it to libc routine.
sysdeps/mach/hurd/htl/pt-sysdep.c(__pthread_self): Remove it.
sysdeps/mach/hurd/htl/pt-sysdep.h(__pthread_self): Add hidden propertie.
htl/Versions(__pthread_self) Version it as private symbol.

Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org>
Message-Id: <20230318095826.1125734-3-gfleury@disroot.org>
2023-04-05 01:26:34 +02:00
Guy-Fleury Iteriteka
7bba5bd8e8 htl: move __pthtread_total into libc
htl/pt-nthreads.c: new file.
htl/Makefile: Add it to routine.
htl/Versions: version it as private libc symbol.
htl/pt-create.c: remove his definition here.
htl/pt-internal.h: add propertie to it declaration.

Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org>
Message-Id: <20230318095826.1125734-2-gfleury@disroot.org>
2023-04-05 01:26:29 +02:00
Sergey Bugaev
166bb3eac3 htl: Move thread table to ld.so
The next commit is going to introduce a new implementation of
THREAD_GSCOPE_WAIT which needs to access the list of threads.
Since it must be usable from the dynamic laoder, we have to move
the symbols for the list of threads into the loader.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20210915171110.226187-2-bugaevc@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-09-16 01:04:05 +02:00
Samuel Thibault
c27bcc9588 htl: Let libc call __pthread_mutex_{,try,un}lock
Now that NPTL was moved to libc, libc makes internal __pthread calls, so
htl has to expose them internally.
2021-07-13 23:36:58 +02:00
Florian Weimer
e9fed2438a linux: Require /dev/shm as the shared memory file system
Previously, glibc would pick an arbitrary tmpfs file system from
/proc/mounts if /dev/shm was not available.  This could lead to
an unsuitable file system being picked for the backing storage for
shm_open, sem_open, and related functions.

This patch introduces a new function, __shm_get_name, which builds
the file name under the appropriate (now hard-coded) directory.  It is
called from the various shm_* and sem_* function.  Unlike the
SHM_GET_NAME macro it replaces, the callers handle the return values
and errno updates.  shm-directory.c is moved directly into the posix
subdirectory because it can be implemented directly using POSIX
functionality.  It resides in libc because it is needed by both
librt and nptl/htl.

In the sem_open implementation, tmpfname is initialized directly
from a string constant.  This happens to remove one alloca call.

Checked on x86_64-linux-gnu.
2021-02-08 14:10:42 -03:00
Samuel Thibault
f9ba73d056 htl: Add missing symbols
hurd/hurdsig.c needs to detect whether __pthread_detach and
__pthread_create are available, so they need to be exposed.
2020-12-03 10:48:27 +01:00
Samuel Thibault
9cec82de71 htl: Initialize later
Since htl does not actually need a stack switch, we can initialize it
like nptl is, avoiding all sorts of startup issues with ifunc.

More precisely, htl defines __pthread_initialize_minimal instead of the
elder _cthread_init_routine. We can then drop the stack switching dances.
2020-11-11 20:41:25 +00:00
Samuel Thibault
a50efac19a htl: Move cleanup stack to variable shared between libc and pthread
If libpthread gets loaded dynamically, the stack needs to already contain the
cleanup handlers of the main thread.

* htl/libc_pthread_init.c (__pthread_cleanup_stack): New per-thread variable.
* htl/Versions (libc): Add __pthread_cleanup_stack as private symbol.
* htl/pt-internal.h (struct __pthread): Remove cancelation_handlers
field.
(__pthread_cleanup_stack): Add variable declaration.
* htl/pt-alloc.c (initialize_pthread): Remove initialization of
cancelation_handlers field.
* htl/pt-cleanup.c (__pthread_get_cleanup_stack): Return the address of
__pthread_cleanup_stack instead of that of the cancelation_handlers
field.
* htl/forward.c: Include <pt-internal.h>.
(dummy_list): Remove variable.
(__pthread_get_cleanup_stack): Return the address of __pthread_cleanup_stack
instead of that of dummy_list.
2020-06-14 15:53:04 +00:00
Samuel Thibault
be22a151f3 htl: Add sem_clockwait support
* sysdeps/htl/sem-timedwait.c (__sem_timedwait_internal): Add clock_id
parameter instead of hardcoding CLOCK_REALTIME.
(__sem_clockwait): New function.
(sem_clockwait): New weak alias.
* sysdeps/htl/sem-wait.c (__sem_timedwait_internal): Update declaration.
(__sem_wait): Update call to __sem_timedwait_internal.
* htl/Versions (GLIBC_2.32): Add sem_clockwait.
* sysdeps/mach/hurd/i386/libpthread.abilist (sem_clockwait): Add symbol.
* nptl/Makefile (tests): Move tst-sem5 to...
* sysdeps/pthread/Makefile (tests): ... here.
2020-06-07 03:14:49 +02:00
Samuel Thibault
28cada0418 htl: Add clock variants
* htl/pt-join.c (__pthread_join): Move implementation to...
(__pthread_join_common): ... new function. Add try, timed and clock support.
(__pthread_join): Reimplement on top of __pthread_join_common.
(__pthread_tryjoin_np, __pthread_timedjoin_np, __pthread_clockjoin_np):
Implement on top of __pthread_join_common.
(pthread_tryjoin_np, pthread_timedjoin_np, pthread_clockjoin_np): New
aliases.

* hurd/hurdlock.c (__lll_abstimed_wait, __lll_abstimed_xwait,
__lll_abstimed_lock): Check for supported clock.

* sysdeps/htl/pt-cond-timedwait.c (__pthread_cond_timedwait_internal):
Add clockid parameter and support it.
(__pthread_cond_timedwait): Pass -1 as clockid.
(__pthread_cond_clockwait): New function.
(pthread_cond_clockwait): New alias.
* sysdeps/htl/pt-cond-wait.c (__pthread_cond_timedwait_internal): Update
prototype.
(__pthread_cond_wait): Pass -1 as clockid.

* sysdeps/htl/pt-rwlock-timedrdlock.c
(__pthread_rwlock_timedrdlock_internal): Add clockid parameter, and
support id.
(__pthread_rwlock_clockrdlock): New function.
(pthread_rwlock_clockrdlock): New alias.
* sysdeps/htl/pt-rwlock-rdlock.c (__pthread_rwlock_timedrdlock_internal): Update
prototype.
(__pthread_rwlock_rdlock): Pass -1 as clockid.

* sysdeps/htl/pt-rwlock-timedwrlock.c
(__pthread_rwlock_timedwrlock_internal): Add clockid parameter, and
support id.
(__pthread_rwlock_clockwrlock): New function.
(pthread_rwlock_clockwrlock): New alias.
* sysdeps/htl/pt-rwlock-wrlock.c (__pthread_rwlock_timedwrlock_internal): Update
prototype.
(__pthread_rwlock_wrlock): Pass -1 as clockid.

* sysdeps/mach/hurd/htl/pt-mutex-timedlock.c (__pthread_mutex_timedlock): Move implementation to
(__pthread_mutex_clocklock): New function with additional clockid
parameter and support it.
(pthread_mutex_clocklock): New alias.
(__pthread_mutex_timedlock): Reimplement on top of __pthread_mutex_clocklock.

* sysdeps/htl/pthread.h (pthread_tryjoin_np, pthread_timedjoin_np,
pthread_clockjoin_np, pthread_mutex_clocklock, pthread_cond_clockwait,
pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock): New prototypes.
* sysdeps/htl/pthreadP.h (__pthread_cond_clockwait): New prototype.

* htl/Versions (GLIBC_2.32): Add pthread_cond_clockwait,
pthread_mutex_clocklock, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock,
pthread_tryjoin_np, pthread_timedjoin_np, pthread_clockjoin_np.
* sysdeps/mach/hurd/i386/libpthread.abilist (pthread_clockjoin_np,
pthread_cond_clockwait, pthread_mutex_clocklock, pthread_rwlock_clockrdlock,
pthread_rwlock_clockwrlock, pthread_timedjoin_np, pthread_tryjoin_np):
New functions.

* nptl/tst-abstime.c, nptl/tst-join10.c, nptl/tst-join11.c, nptl/tst-join12.c,
nptl/tst-join13.c, nptl/tst-join14.c, nptl/tst-join2.c, nptl/tst-join3.c,
nptl/tst-join8.c, nptl/tst-join9.c, nptl/tst-mutex-errorcheck.c,
nptl/tst-pthread-mutexattr.c, nptl/tst-mutex11.c, nptl/tst-mutex5.c,
nptl/tst-mutex7.c, nptl/tst-mutex7robus.c, nptl/tst-mutex9.c,
nptl/tst-rwlock12.c, nptl/tst-rwlock14.c: Move to sysdeps/pthread.
* sysdeps/pthread/tst-mutex8.c: Move back to nptl.
* nptl/Makefile (tests): Move tst-mutex5, tst-mutex7, tst-mutex7robust,
tst-mutex9, tst-mutex11, tst-rwlock12, tst-rwlock14, tst-join2, tst-join3,
tst-join8, tst-join9 tst-join10, tst-join11, tst-join12, tst-join13, tst-join14,
tst-abstime, tst-mutex-errorcheck, tst-pthread-mutexattr to ...
* sysdeps/pthread/Makefile (tests): ... here.
2020-05-26 00:46:07 +00:00
Samuel Thibault
6c43d94a96 htl: Add missing functions and defines for robust mutexes 2020-02-16 14:08:56 +00:00
Samuel Thibault
59b7fe99f2 htl: Add support for libc cancellation points 2020-02-10 01:03:50 +00:00
Samuel Thibault
b05de10400 C11 threads: Move implementation to sysdeps/pthread
so it gets shared by nptl and htl. Also add htl versions of thrd_current and
thrd_yield.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-02-09 13:56:48 +01:00
Samuel Thibault
e775f443bd htl: Rename _pthread_mutex_init/destroy to __pthread_mutex_init/destroy 2020-02-09 13:56:45 +01:00
Samuel Thibault
0093df204a htl: Move internal mutex/rwlock symbols to GLIBC_PRIVATE
Their prototypes have never been made public, and they are not used outside
libc (checked on the whole Debian archive)
2020-02-09 13:06:35 +01:00
Samuel Thibault
a99155555c htl: Remove unused files
These have never been used.
2020-02-09 01:27:38 +01:00
Samuel Thibault
a8f0fc4e5f htl: Add internal version of __pthread_mutex_timedlock
The C11 threads implementation will need it.
2020-01-13 20:41:07 +01:00
Samuel Thibault
25c084e0a7 htl: Add __errno_location and __h_errno_location
As explained on
https://sourceware.org/ml/libc-alpha/2020-01/msg00049.html
the presence of __errno_location in libpthread.so on GNU/Linux makes
libpthread getting linked in for libstdc++. This aligns on that behavior, to
avoid issues that only GNU/Hurd would get.
2020-01-04 19:37:53 +01:00
Samuel Thibault
b5403eca16 hurd: Add missing symbols for proper libc_get/setspecific
* htl/Versions (__pthread_getspecific, __pthread_setspecific): Add
	symbols.
2018-08-08 01:55:04 +02:00
Samuel Thibault
33574c17ee hurd: Add hurd thread library
Contributed by

Agustina Arzille <avarzille@riseup.net>
Amos Jeffries <squid3@treenet.co.nz>
David Michael <fedora.dm0@gmail.com>
Marco Gerards <marco@gnu.org>
Marcus Brinkmann <marcus@gnu.org>
Neal H. Walfield <neal@gnu.org>
Pino Toscano <toscano.pino@tiscali.it>
Richard Braun <rbraun@sceen.net>
Roland McGrath <roland@gnu.org>
Samuel Thibault <samuel.thibault@ens-lyon.org>
Thomas DiModica <ricinwich@yahoo.com>
Thomas Schwinge <tschwinge@gnu.org>

	* htl: New directory.
	* sysdeps/htl: New directory.
	* sysdeps/hurd/htl: New directory.
	* sysdeps/i386/htl: New directory.
	* sysdeps/mach/htl: New directory.
	* sysdeps/mach/hurd/htl: New directory.
	* sysdeps/mach/hurd/i386/htl: New directory.
	* nscd/Depend, resolv/Depend, rt/Depend: Add htl dependency.
	* sysdeps/mach/hurd/i386/Implies: Add mach/hurd/i386/htl imply.
	* sysdeps/mach/hurd/i386/libpthread.abilist: New file.
2018-04-02 01:44:14 +02:00