aboutsummaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-04-21 19:49:50 +0200
committerFlorian Weimer <fweimer@redhat.com>2021-04-21 19:49:50 +0200
commit3fec7f18bfcb7044e813a12e19c3c98eb8387e26 (patch)
tree63320bd00d52f0437c4f8676fbff561311dfdb8f /nptl
parent4647ce82c733d1453611e35236b786ecd7faf598 (diff)
downloadglibc-3fec7f18bfcb7044e813a12e19c3c98eb8387e26.zip
glibc-3fec7f18bfcb7044e813a12e19c3c98eb8387e26.tar.gz
glibc-3fec7f18bfcb7044e813a12e19c3c98eb8387e26.tar.bz2
nptl: Move pthread_once and __pthread_once into libc
And also the fork generation counter, __fork_generation. This eliminates the need for __fork_generation_pointer. call_once remains in libpthread and calls the exported __pthread_once symbol. pthread_once and __pthread_once have been moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'nptl')
-rw-r--r--nptl/Makefile2
-rw-r--r--nptl/Versions6
-rw-r--r--nptl/libc_pthread_init.c8
-rw-r--r--nptl/nptl-init.c4
-rw-r--r--nptl/pthreadP.h8
-rw-r--r--nptl/pthread_once.c15
6 files changed, 21 insertions, 22 deletions
diff --git a/nptl/Makefile b/nptl/Makefile
index b53d32e..323bcc9 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -77,6 +77,7 @@ routines = \
pthread_getschedparam \
pthread_kill \
pthread_mutex_consistent \
+ pthread_once \
pthread_self \
pthread_setschedparam \
pthread_sigmask \
@@ -162,7 +163,6 @@ libpthread-routines = \
pthread_mutexattr_setpshared \
pthread_mutexattr_setrobust \
pthread_mutexattr_settype \
- pthread_once \
pthread_rwlock_clockrdlock \
pthread_rwlock_clockwrlock \
pthread_rwlock_destroy \
diff --git a/nptl/Versions b/nptl/Versions
index e59a117..1a7946c 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -1,5 +1,6 @@
libc {
GLIBC_2.0 {
+ __pthread_once;
_pthread_cleanup_pop;
_pthread_cleanup_pop_restore;
_pthread_cleanup_push;
@@ -32,6 +33,7 @@ libc {
pthread_mutex_init;
pthread_mutex_lock;
pthread_mutex_unlock;
+ pthread_once;
pthread_self;
pthread_setcancelstate;
pthread_setcanceltype;
@@ -84,8 +86,10 @@ libc {
}
GLIBC_2.34 {
__pthread_cleanup_routine;
+ __pthread_once;
pthread_kill;
pthread_mutex_consistent;
+ pthread_once;
}
GLIBC_PRIVATE {
__futex_abstimed_wait64;
@@ -135,7 +139,6 @@ libpthread {
__pthread_mutexattr_destroy;
__pthread_mutexattr_init;
__pthread_mutexattr_settype;
- __pthread_once;
__pthread_setspecific;
_exit;
flockfile;
@@ -164,7 +167,6 @@ libpthread {
pthread_mutexattr_getkind_np;
pthread_mutexattr_init;
pthread_mutexattr_setkind_np;
- pthread_once;
pthread_setcancelstate;
pthread_setcanceltype;
pthread_setspecific;
diff --git a/nptl/libc_pthread_init.c b/nptl/libc_pthread_init.c
index 4de182b..b67a69f 100644
--- a/nptl/libc_pthread_init.c
+++ b/nptl/libc_pthread_init.c
@@ -28,9 +28,6 @@
#include <ldsodefs.h>
-unsigned long int *__fork_generation_pointer;
-
-
#ifdef TLS_MULTIPLE_THREADS_IN_TCB
void
#else
@@ -38,12 +35,9 @@ extern int __libc_multiple_threads attribute_hidden;
int *
#endif
-__libc_pthread_init (unsigned long int *ptr, void (*reclaim) (void),
+__libc_pthread_init (void (*reclaim) (void),
const struct pthread_functions *functions)
{
- /* Remember the pointer to the generation counter in libpthread. */
- __fork_generation_pointer = ptr;
-
/* Called by a child after fork. */
__register_atfork (NULL, NULL, reclaim, NULL);
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index 9decc14..b683adb 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -87,7 +87,6 @@ static const struct pthread_functions pthread_functions =
.ptr_pthread_mutex_unlock = __pthread_mutex_unlock,
.ptr___pthread_setcancelstate = __pthread_setcancelstate,
.ptr_pthread_setcanceltype = __pthread_setcanceltype,
- .ptr___pthread_once = __pthread_once,
.ptr___pthread_rwlock_rdlock = __pthread_rwlock_rdlock,
.ptr___pthread_rwlock_wrlock = __pthread_rwlock_wrlock,
.ptr___pthread_rwlock_unlock = __pthread_rwlock_unlock,
@@ -333,8 +332,7 @@ __pthread_initialize_minimal_internal (void)
#ifndef TLS_MULTIPLE_THREADS_IN_TCB
__libc_multiple_threads_ptr =
#endif
- __libc_pthread_init (&__fork_generation, __reclaim_stacks,
- ptr_pthread_functions);
+ __libc_pthread_init (__reclaim_stacks, ptr_pthread_functions);
#if HAVE_TUNABLES
__pthread_tunables_init ();
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index ab0e92f..75fec43 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -361,12 +361,10 @@ extern unsigned long int *__fork_generation_pointer attribute_hidden;
/* Register the generation counter in the libpthread with the libc. */
#ifdef TLS_MULTIPLE_THREADS_IN_TCB
-extern void __libc_pthread_init (unsigned long int *ptr,
- void (*reclaim) (void),
+extern void __libc_pthread_init (void (*reclaim) (void),
const struct pthread_functions *functions);
#else
-extern int *__libc_pthread_init (unsigned long int *ptr,
- void (*reclaim) (void),
+extern int *__libc_pthread_init (void (*reclaim) (void),
const struct pthread_functions *functions);
/* Variable set to a nonzero value either if more than one thread runs or ran,
@@ -525,6 +523,7 @@ extern void *__pthread_getspecific (pthread_key_t key);
extern int __pthread_setspecific (pthread_key_t key, const void *value);
extern int __pthread_once (pthread_once_t *once_control,
void (*init_routine) (void));
+libc_hidden_proto (__pthread_once)
extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void),
void (*child) (void));
extern pthread_t __pthread_self (void);
@@ -557,7 +556,6 @@ hidden_proto (__pthread_rwlock_unlock)
hidden_proto (__pthread_key_create)
hidden_proto (__pthread_getspecific)
hidden_proto (__pthread_setspecific)
-hidden_proto (__pthread_once)
hidden_proto (__pthread_setcancelstate)
hidden_proto (__pthread_testcancel)
hidden_proto (__pthread_mutexattr_init)
diff --git a/nptl/pthread_once.c b/nptl/pthread_once.c
index 7645da2..323583c 100644
--- a/nptl/pthread_once.c
+++ b/nptl/pthread_once.c
@@ -19,7 +19,8 @@
#include "pthreadP.h"
#include <futex-internal.h>
#include <atomic.h>
-
+#include <libc-lockP.h>
+#include <shlib-compat.h>
unsigned long int __fork_generation attribute_hidden;
@@ -132,7 +133,7 @@ __pthread_once_slow (pthread_once_t *once_control, void (*init_routine) (void))
}
int
-__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
+___pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
{
/* Fast path. See __pthread_once_slow. */
int val;
@@ -142,5 +143,11 @@ __pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
else
return __pthread_once_slow (once_control, init_routine);
}
-weak_alias (__pthread_once, pthread_once)
-hidden_def (__pthread_once)
+versioned_symbol (libc, ___pthread_once, __pthread_once, GLIBC_2_34);
+libc_hidden_ver (___pthread_once, __pthread_once)
+
+versioned_symbol (libc, ___pthread_once, pthread_once, GLIBC_2_34);
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34)
+compat_symbol (libpthread, ___pthread_once, __pthread_once, GLIBC_2_0);
+compat_symbol (libpthread, ___pthread_once, pthread_once, GLIBC_2_0);
+#endif