diff --git a/htl/Makefile b/htl/Makefile index f841b33b51..e59a7fff68 100644 --- a/htl/Makefile +++ b/htl/Makefile @@ -25,11 +25,9 @@ SYSDEPS := LCLHDRS := libpthread-routines := \ - pt-create \ pt-spin-inlines \ pt-hurd-cond-wait \ pt-hurd-cond-timedwait \ - pt-sysdep \ pt-spin \ pt-getname-np \ pt-setname-np \ @@ -115,6 +113,7 @@ routines := \ pt-condattr-init \ pt-condattr-setclock \ pt-condattr-setpshared \ + pt-create \ pt-dealloc \ pt-destroy-specific \ pt-detach \ @@ -185,6 +184,7 @@ routines := \ pt-sigstate-init \ pt-stack-alloc \ pt-startup \ + pt-sysdep \ pt-testcancel \ pt-thread-alloc \ pt-thread-start \ diff --git a/htl/Versions b/htl/Versions index 280459c2a6..d46490b3a5 100644 --- a/htl/Versions +++ b/htl/Versions @@ -53,6 +53,7 @@ libc { pthread_condattr_getpshared; pthread_condattr_setclock; pthread_condattr_setpshared; + pthread_create; pthread_detach; pthread_getattr_np; pthread_getconcurrency; @@ -219,6 +220,7 @@ libc { GLIBC_2.43 { pthread_cancel; pthread_clockjoin_np; + pthread_create; pthread_detach; pthread_getattr_np; pthread_getconcurrency; @@ -252,6 +254,7 @@ libc { __pthread_alloc; __pthread_block; __pthread_block_intr; + __pthread_create; __pthread_init_thread; __pthread_init_static_tls; __pthread_default_attr; @@ -279,6 +282,7 @@ libc { __pthread_destroy_specific; __pthread_exit; __pthread_getspecific; + __pthread_initialize_minimal; __pthread_join; __pthread_key_delete; __pthread_max_threads; @@ -316,8 +320,6 @@ libpthread { GLIBC_2.12 { pthread_atfork; - pthread_create; - pthread_spin_destroy; pthread_spin_init; pthread_spin_lock; pthread_spin_trylock; pthread_spin_unlock; __pthread_spin_destroy; __pthread_spin_init; @@ -342,10 +344,4 @@ libpthread { pthread_getname_np; pthread_setname_np; } - - GLIBC_PRIVATE { - __pthread_initialize_minimal; - - __pthread_create; - } } diff --git a/htl/pt-create.c b/htl/pt-create.c index d3fee29d20..820037e8a9 100644 --- a/htl/pt-create.c +++ b/htl/pt-create.c @@ -25,13 +25,14 @@ #include #include #include +#include +#include #include #include -#if IS_IN (libpthread) -# include -#endif +#include + #ifdef HAVE_USELOCALE # include #endif @@ -45,10 +46,9 @@ entry_point (struct __pthread *self, void *(*start_routine) (void *), void *arg) ___pthread_self = self; __resp = &self->res_state; -#if IS_IN (libpthread) /* Initialize pointers to locale data. */ __ctype_init (); -#endif + #ifdef HAVE_USELOCALE /* A fresh thread needs to be bound to the global locale. */ uselocale (LC_GLOBAL_LOCALE); @@ -78,6 +78,24 @@ entry_point (struct __pthread *self, void *(*start_routine) (void *), void *arg) int __pthread_create (pthread_t * thread, const pthread_attr_t * attr, void *(*start_routine) (void *), void *arg) +{ + /* Avoid a data race in the multi-threaded case. */ + if (__libc_single_threaded) + __libc_single_threaded = 0; + + return __libc_pthread_create (thread, attr, start_routine, arg); +} +versioned_symbol (libc, __pthread_create, pthread_create, GLIBC_2_43); +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_43) +compat_symbol (libpthread, __pthread_create, pthread_create, GLIBC_2_12); +#endif +hidden_def (__pthread_create) + +/* Version of pthread_create which does not make __libc_single_threaded zero. + This is notably useful for the signal thread. */ +int +__libc_pthread_create (pthread_t * thread, const pthread_attr_t * attr, + void *(*start_routine) (void *), void *arg) { int err; struct __pthread *pthread; @@ -90,8 +108,6 @@ __pthread_create (pthread_t * thread, const pthread_attr_t * attr, return err; } -weak_alias (__pthread_create, pthread_create) -hidden_def (__pthread_create) /* Internal version of pthread_create. See comment in pt-internal.h. */ @@ -106,10 +122,6 @@ __pthread_create_internal (struct __pthread **thread, sigset_t sigset; size_t stacksize; - /* Avoid a data race in the multi-threaded case. */ - if (__libc_single_threaded) - __libc_single_threaded = 0; - /* Allocate a new thread structure. */ err = __pthread_alloc (&pthread); if (err) diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c index 672bc06f88..ab02b1d7e5 100644 --- a/hurd/hurdsig.c +++ b/hurd/hurdsig.c @@ -1519,8 +1519,8 @@ _hurdsig_init (const int *intarray, size_t intarraysize) /* Start the signal thread listening on the message port. */ -#pragma weak __pthread_create - if (!__pthread_create) +#pragma weak __libc_pthread_create + if (!__libc_pthread_create) { err = __thread_create (__mach_task_self (), &_hurd_msgport_thread); assert_perror (err); @@ -1564,7 +1564,7 @@ _hurdsig_init (const int *intarray, size_t intarraysize) #pragma weak __pthread_detach #pragma weak __pthread_getattr_np #pragma weak __pthread_attr_getstack - __pthread_create(&thread, NULL, &_hurd_msgport_receive, NULL); + __libc_pthread_create (&thread, NULL, &_hurd_msgport_receive, NULL); /* Record signal thread stack layout for fork() */ __pthread_getattr_np (thread, &attr); diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h index 471a4cfa43..5fb6469714 100644 --- a/sysdeps/htl/pthreadP.h +++ b/sysdeps/htl/pthreadP.h @@ -24,7 +24,6 @@ #include #include #include -#include /* Attribute to indicate thread creation was issued from C11 thrd_create. */ #define ATTR_C11_THREAD ((void*)(uintptr_t)-1) @@ -170,6 +169,8 @@ libc_hidden_proto (__pthread_setcanceltype); extern int __pthread_sigmask (int, const sigset_t *, sigset_t *); libc_hidden_proto (__pthread_sigmask); +int __libc_pthread_create (pthread_t * thread, const pthread_attr_t * attr, + void *(*start_routine) (void *), void *arg); int __pthread_create (pthread_t *newthread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); @@ -232,9 +233,7 @@ libc_hidden_proto (__pthread_attr_init) libc_hidden_proto (__pthread_condattr_init) libc_hidden_proto (__pthread_get_cleanup_stack) -#if IS_IN (libpthread) -hidden_proto (__pthread_create) -#endif +libc_hidden_proto (__pthread_create) #define ASSERT_TYPE_SIZE(type, size) \ _Static_assert (sizeof (type) == size, \ diff --git a/sysdeps/mach/hurd/htl/pt-sysdep.c b/sysdeps/mach/hurd/htl/pt-sysdep.c index 43745095bf..4d6a710ca8 100644 --- a/sysdeps/mach/hurd/htl/pt-sysdep.c +++ b/sysdeps/mach/hurd/htl/pt-sysdep.c @@ -26,6 +26,9 @@ #include #include #include +#include +#include +#include static void reset_pthread_total (void) @@ -118,7 +121,7 @@ _init_routine (void *stack) when we return from here) shouldn't be seen as a user thread. */ __pthread_total--; - __pthread_atfork (NULL, NULL, reset_pthread_total); + __register_atfork (NULL, NULL, reset_pthread_total, __dso_handle); GL(dl_init_static_tls) = &__pthread_init_static_tls; @@ -131,12 +134,3 @@ __pthread_initialize_minimal (void) { _init_routine (__libc_stack_end); } - -#ifdef SHARED -__attribute__ ((constructor)) -static void -dynamic_init_routine (void) -{ - _init_routine (__libc_stack_end); -} -#endif diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist index bbd00ed11a..f7c323c834 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -76,6 +76,7 @@ GLIBC_2.12 pthread_condattr_getpshared F GLIBC_2.12 pthread_condattr_init F GLIBC_2.12 pthread_condattr_setclock F GLIBC_2.12 pthread_condattr_setpshared F +GLIBC_2.12 pthread_create F GLIBC_2.12 pthread_detach F GLIBC_2.12 pthread_equal F GLIBC_2.12 pthread_exit F @@ -2670,6 +2671,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 pthread_cancel F GLIBC_2.43 pthread_clockjoin_np F +GLIBC_2.43 pthread_create F GLIBC_2.43 pthread_detach F GLIBC_2.43 pthread_getattr_np F GLIBC_2.43 pthread_getconcurrency F diff --git a/sysdeps/mach/hurd/i386/libpthread.abilist b/sysdeps/mach/hurd/i386/libpthread.abilist index c55b78b01c..e1844a8f5e 100644 --- a/sysdeps/mach/hurd/i386/libpthread.abilist +++ b/sysdeps/mach/hurd/i386/libpthread.abilist @@ -5,7 +5,6 @@ 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_create F GLIBC_2.12 pthread_spin_destroy F GLIBC_2.12 pthread_spin_init F GLIBC_2.12 pthread_spin_lock F diff --git a/sysdeps/mach/hurd/x86_64/libc.abilist b/sysdeps/mach/hurd/x86_64/libc.abilist index 5fb477342e..b482d2d040 100644 --- a/sysdeps/mach/hurd/x86_64/libc.abilist +++ b/sysdeps/mach/hurd/x86_64/libc.abilist @@ -1556,6 +1556,7 @@ GLIBC_2.38 pthread_condattr_getpshared F GLIBC_2.38 pthread_condattr_init F GLIBC_2.38 pthread_condattr_setclock F GLIBC_2.38 pthread_condattr_setpshared F +GLIBC_2.38 pthread_create F GLIBC_2.38 pthread_detach F GLIBC_2.38 pthread_equal F GLIBC_2.38 pthread_exit F @@ -2348,6 +2349,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 pthread_cancel F GLIBC_2.43 pthread_clockjoin_np F +GLIBC_2.43 pthread_create F GLIBC_2.43 pthread_detach F GLIBC_2.43 pthread_getattr_np F GLIBC_2.43 pthread_getconcurrency F diff --git a/sysdeps/mach/hurd/x86_64/libpthread.abilist b/sysdeps/mach/hurd/x86_64/libpthread.abilist index 77d9a6601d..d4ae93df53 100644 --- a/sysdeps/mach/hurd/x86_64/libpthread.abilist +++ b/sysdeps/mach/hurd/x86_64/libpthread.abilist @@ -17,7 +17,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_create F GLIBC_2.38 pthread_hurd_cond_timedwait_np F GLIBC_2.38 pthread_hurd_cond_wait_np F GLIBC_2.38 pthread_spin_destroy F