From af27fabe405c757d372b106c8aa383a386a4a79e Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 7 Jun 2020 23:27:46 +0000 Subject: htl: Fix tls initialization for already-created threads * sysdeps/htl/pthreadP.h: Include (__pthread_init_static_tls): New prototype. * htl/pt-alloc.c (__pthread_init_static_tls): New function. * sysdeps/mach/hurd/htl/pt-sysdep.c (_init_routine): Initialize tcb field of initial thread. Set GL(dl_init_static_tls) to &__pthread_init_static_tls. --- sysdeps/htl/pthreadP.h | 3 +++ sysdeps/mach/hurd/htl/pt-sysdep.c | 3 +++ 2 files changed, 6 insertions(+) (limited to 'sysdeps') diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h index 7486c93..0eb969e 100644 --- a/sysdeps/htl/pthreadP.h +++ b/sysdeps/htl/pthreadP.h @@ -22,10 +22,13 @@ #define __PTHREAD_HTL #include +#include /* Attribute to indicate thread creation was issued from C11 thrd_create. */ #define ATTR_C11_THREAD ((void*)(uintptr_t)-1) +extern void __pthread_init_static_tls (struct link_map *) attribute_hidden; + /* These represent the interface used by glibc itself. */ extern pthread_t __pthread_self (void); diff --git a/sysdeps/mach/hurd/htl/pt-sysdep.c b/sysdeps/mach/hurd/htl/pt-sysdep.c index 84d1914..0963b44 100644 --- a/sysdeps/mach/hurd/htl/pt-sysdep.c +++ b/sysdeps/mach/hurd/htl/pt-sysdep.c @@ -77,6 +77,7 @@ _init_routine (void *stack) to the new stack. Pretend it wasn't allocated so that it remains valid if the main thread terminates. */ thread->stack = 0; + thread->tcb = THREAD_SELF; #ifndef PAGESIZE __pthread_default_attr.__guardsize = __vm_page_size; @@ -91,6 +92,8 @@ _init_routine (void *stack) __pthread_atfork (NULL, NULL, reset_pthread_total); + GL(dl_init_static_tls) = &__pthread_init_static_tls; + /* Make MiG code thread aware. */ __mig_init (thread->stackaddr); -- cgit v1.1