htl: move pthread_key_*, pthread_get/setspecific

Signed-off-by: gfleury <gfleury@disroot.org>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-ID: <20250613184440.1660335-1-gfleury@disroot.org>
This commit is contained in:
gfleury 2025-06-13 20:43:48 +02:00 committed by Samuel Thibault
parent 90cf97bb9d
commit 27360ab9ea
16 changed files with 76 additions and 47 deletions

View File

@ -25,12 +25,7 @@ SYSDEPS := lockfile
LCLHDRS :=
libpthread-routines := \
pt-destroy-specific \
pt-init-specific \
pt-key-create \
pt-key-delete \
pt-getspecific \
pt-setspecific \
pt-alloc \
pt-create \
pt-getattr \
@ -161,7 +156,11 @@ routines := \
pt-condattr-init \
pt-condattr-setclock \
pt-condattr-setpshared \
pt-destroy-specific \
pt-getschedparam \
pt-getspecific \
pt-key-create \
pt-key-delete \
pt-mutex-checklocked \
pt-mutex-consistent \
pt-mutex-destroy \
@ -205,6 +204,7 @@ routines := \
pt-setcancelstate \
pt-setcanceltype \
pt-setschedparam \
pt-setspecific \
pt-sigmask \
pt-sigstate \
pt-sigstate-destroy \

View File

@ -2,6 +2,7 @@ libc {
GLIBC_2.12 {
pthread_self;
__pthread_key_create;
__pthread_self;
pthread_attr_getdetachstate;
pthread_attr_getinheritsched;
@ -12,6 +13,7 @@ libc {
pthread_attr_setschedpolicy;
pthread_equal;
pthread_getschedparam;
pthread_getspecific;
pthread_setschedparam;
pthread_attr_destroy;
pthread_attr_getguardsize;
@ -45,6 +47,8 @@ libc {
pthread_condattr_getpshared;
pthread_condattr_setclock;
pthread_condattr_setpshared;
pthread_key_create;
pthread_key_delete;
pthread_mutex_destroy;
pthread_mutex_getprioceiling;
pthread_mutex_init;
@ -79,6 +83,7 @@ libc {
pthread_rwlockattr_setpshared;
pthread_setcancelstate;
pthread_setcanceltype;
pthread_setspecific;
pthread_sigmask;
}
@ -154,6 +159,9 @@ libc {
pthread_barrierattr_getpshared;
pthread_barrierattr_init;
pthread_barrierattr_setpshared;
pthread_getspecific;
pthread_key_create;
pthread_key_delete;
pthread_mutex_consistent; pthread_mutex_consistent_np;
pthread_mutex_getprioceiling;
pthread_mutex_setprioceiling;
@ -174,6 +182,7 @@ libc {
pthread_rwlockattr_getpshared;
pthread_rwlockattr_init;
pthread_rwlockattr_setpshared;
pthread_setspecific;
}
GLIBC_PRIVATE {
@ -203,6 +212,9 @@ libc {
__pthread_cond_wait;
__pthread_condattr_init;
__pthread_default_condattr;
__pthread_destroy_specific;
__pthread_getspecific;
__pthread_key_delete;
__pthread_mutex_checklocked;
__pthread_mutex_destroy;
__pthread_mutex_init;
@ -214,6 +226,7 @@ libc {
__pthread_mutexattr_init;
__pthread_mutexattr_settype;
__pthread_once;
__pthread_setspecific;
__pthread_sigstate;
__pthread_sigstate_destroy;
__pthread_sigmask;
@ -255,20 +268,16 @@ libpthread {
pthread_getattr_np;
pthread_getconcurrency; pthread_getcpuclockid;
pthread_getspecific;
pthread_join;
pthread_key_create; pthread_key_delete;
__pthread_key_create;
pthread_kill;
__pthread_kill;
pthread_mutex_transfer_np;
pthread_setconcurrency;
pthread_setschedprio; pthread_setspecific;
pthread_setschedprio;
pthread_testcancel;
pthread_yield;
@ -315,8 +324,6 @@ libpthread {
__cthread_keycreate;
__cthread_getspecific;
__cthread_setspecific;
__pthread_getspecific;
__pthread_setspecific;
__pthread_getattr_np;
__pthread_enable_asynccancel;
__pthread_disable_asynccancel;

View File

@ -30,9 +30,6 @@ static const struct pthread_functions pthread_functions = {
.ptr___pthread_exit = __pthread_exit,
.ptr___pthread_get_cleanup_stack = __pthread_get_cleanup_stack,
.ptr_pthread_once = __pthread_once,
.ptr___pthread_key_create = __pthread_key_create,
.ptr___pthread_getspecific = __pthread_getspecific,
.ptr___pthread_setspecific = __pthread_setspecific,
.ptr__IO_flockfile = _cthreads_flockfile,
.ptr__IO_funlockfile = _cthreads_funlockfile,
.ptr__IO_ftrylockfile = _cthreads_ftrylockfile,

View File

@ -299,6 +299,7 @@ extern error_t __pthread_init_specific (struct __pthread *thread);
/* Call the destructors on all of the thread specific data in THREAD.
THREAD must be the calling thread. */
extern void __pthread_destroy_specific (struct __pthread *thread);
libc_hidden_proto (__pthread_destroy_specific)
/* Initialize newly create thread *THREAD's signal state data

View File

@ -126,15 +126,9 @@ libc_hidden_proto (__pthread_setcancelstate)
single-threaded processes. */
#if !defined(__NO_WEAK_PTHREAD_ALIASES) && !IS_IN (libpthread)
# ifdef weak_extern
weak_extern (__pthread_key_create)
weak_extern (__pthread_setspecific)
weak_extern (__pthread_getspecific)
weak_extern (__pthread_initialize)
weak_extern (__pthread_atfork)
# else
# pragma weak __pthread_key_create
# pragma weak __pthread_setspecific
# pragma weak __pthread_getspecific
# pragma weak __pthread_initialize
# pragma weak __pthread_atfork
# endif

View File

@ -20,6 +20,7 @@
#include <stdlib.h>
#include <pt-internal.h>
#include <string.h>
void
__pthread_destroy_specific (struct __pthread *thread)
@ -100,3 +101,4 @@ __pthread_destroy_specific (struct __pthread *thread)
memset (&thread->static_thread_specifics, 0,
sizeof (thread->static_thread_specifics));
}
libc_hidden_def (__pthread_destroy_specific)

View File

@ -19,6 +19,7 @@
#include <pthread.h>
#include <pt-internal.h>
#include <shlib-compat.h>
void *
__pthread_getspecific (pthread_key_t key)
@ -42,5 +43,9 @@ __pthread_getspecific (pthread_key_t key)
return self->thread_specifics[key];
}
weak_alias (__pthread_getspecific, pthread_getspecific);
hidden_def (__pthread_getspecific)
libc_hidden_def (__pthread_getspecific)
versioned_symbol (libc, __pthread_getspecific, pthread_getspecific, GLIBC_2_42);
#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_42)
compat_symbol (libpthread, __pthread_getspecific, pthread_getspecific, GLIBC_2_12);
#endif

View File

@ -22,6 +22,9 @@
#include <pt-internal.h>
#include <pthreadP.h>
#include <shlib-compat.h>
#include <ldsodefs.h>
pthread_mutex_t __pthread_key_lock;
pthread_once_t __pthread_key_once = PTHREAD_ONCE_INIT;
@ -116,5 +119,9 @@ do_search:
__pthread_mutex_unlock (&__pthread_key_lock);
return 0;
}
weak_alias (__pthread_key_create, pthread_key_create)
hidden_def (__pthread_key_create)
libc_hidden_def (__pthread_key_create)
versioned_symbol (libc, __pthread_key_create, pthread_key_create, GLIBC_2_42);
#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_42)
compat_symbol (libpthread, __pthread_key_create, pthread_key_create, GLIBC_2_12);
#endif

View File

@ -19,6 +19,8 @@
#include <pthread.h>
#include <pt-internal.h>
#include <shlib-compat.h>
#include <ldsodefs.h>
int
__pthread_key_delete (pthread_key_t key)
@ -69,4 +71,9 @@ __pthread_key_delete (pthread_key_t key)
return err;
}
weak_alias (__pthread_key_delete, pthread_key_delete)
libc_hidden_def (__pthread_key_delete)
versioned_symbol (libc, __pthread_key_delete, pthread_key_delete, GLIBC_2_42);
#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_42)
compat_symbol (libpthread, __pthread_key_delete, pthread_key_delete, GLIBC_2_12);
#endif

View File

@ -19,6 +19,8 @@
#include <pthread.h>
#include <pt-internal.h>
#include <shlib-compat.h>
#include <string.h>
int
__pthread_setspecific (pthread_key_t key, const void *value)
@ -68,5 +70,9 @@ __pthread_setspecific (pthread_key_t key, const void *value)
self->thread_specifics[key] = (void *) value;
return 0;
}
weak_alias (__pthread_setspecific, pthread_setspecific);
hidden_def (__pthread_setspecific)
libc_hidden_def (__pthread_setspecific)
versioned_symbol (libc, __pthread_setspecific, pthread_setspecific, GLIBC_2_42);
#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_42)
compat_symbol (libpthread, __pthread_setspecific, pthread_setspecific, GLIBC_2_12);
#endif

View File

@ -24,9 +24,6 @@
void __pthread_exit (void *) __attribute__ ((__noreturn__));
struct __pthread_cancelation_handler **__pthread_get_cleanup_stack (void);
int __pthread_once (pthread_once_t *, void (*) (void));
int __pthread_key_create (pthread_key_t *, void (*) (void *));
void *__pthread_getspecific (pthread_key_t);
int __pthread_setspecific (pthread_key_t, const void *);
void _cthreads_flockfile (FILE *);
void _cthreads_funlockfile (FILE *);
@ -40,9 +37,6 @@ struct pthread_functions
void (*ptr___pthread_exit) (void *) __attribute__ ((__noreturn__));
struct __pthread_cancelation_handler **(*ptr___pthread_get_cleanup_stack) (void);
int (*ptr_pthread_once) (pthread_once_t *, void (*) (void));
int (*ptr___pthread_key_create) (pthread_key_t *, void (*) (void *));
void *(*ptr___pthread_getspecific) (pthread_key_t);
int (*ptr___pthread_setspecific) (pthread_key_t, const void *);
void (*ptr__IO_flockfile) (FILE *);
void (*ptr__IO_funlockfile) (FILE *);
int (*ptr__IO_ftrylockfile) (FILE *);

View File

@ -182,9 +182,13 @@ 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);
libc_hidden_proto (__pthread_getspecific)
int __pthread_setspecific (pthread_key_t key, const void *value);
libc_hidden_proto (__pthread_setspecific)
int __pthread_key_delete (pthread_key_t key);
libc_hidden_proto (__pthread_key_delete)
int __pthread_once (pthread_once_t *once_control, void (*init_routine) (void));
int __pthread_getattr_np (pthread_t, pthread_attr_t *);
@ -216,9 +220,6 @@ libc_hidden_proto (__pthread_condattr_init)
#if IS_IN (libpthread)
hidden_proto (__pthread_create)
hidden_proto (__pthread_detach)
hidden_proto (__pthread_key_create)
hidden_proto (__pthread_getspecific)
hidden_proto (__pthread_setspecific)
hidden_proto (__pthread_get_cleanup_stack)
#endif

View File

@ -28,6 +28,7 @@ GLIBC_2.11 mkostemps F
GLIBC_2.11 mkostemps64 F
GLIBC_2.11 mkstemps F
GLIBC_2.11 mkstemps64 F
GLIBC_2.12 __pthread_key_create F
GLIBC_2.12 __pthread_self F
GLIBC_2.12 pthread_attr_destroy F
GLIBC_2.12 pthread_attr_getdetachstate F
@ -70,6 +71,9 @@ GLIBC_2.12 pthread_condattr_setclock F
GLIBC_2.12 pthread_condattr_setpshared F
GLIBC_2.12 pthread_equal F
GLIBC_2.12 pthread_getschedparam F
GLIBC_2.12 pthread_getspecific F
GLIBC_2.12 pthread_key_create F
GLIBC_2.12 pthread_key_delete F
GLIBC_2.12 pthread_mutex_destroy F
GLIBC_2.12 pthread_mutex_getprioceiling F
GLIBC_2.12 pthread_mutex_init F
@ -106,6 +110,7 @@ GLIBC_2.12 pthread_self F
GLIBC_2.12 pthread_setcancelstate F
GLIBC_2.12 pthread_setcanceltype F
GLIBC_2.12 pthread_setschedparam F
GLIBC_2.12 pthread_setspecific F
GLIBC_2.12 pthread_sigmask F
GLIBC_2.13 __fentry__ F
GLIBC_2.14 syncfs F
@ -2593,6 +2598,9 @@ GLIBC_2.42 pthread_barrierattr_destroy F
GLIBC_2.42 pthread_barrierattr_getpshared F
GLIBC_2.42 pthread_barrierattr_init F
GLIBC_2.42 pthread_barrierattr_setpshared F
GLIBC_2.42 pthread_getspecific F
GLIBC_2.42 pthread_key_create F
GLIBC_2.42 pthread_key_delete F
GLIBC_2.42 pthread_mutex_consistent F
GLIBC_2.42 pthread_mutex_consistent_np F
GLIBC_2.42 pthread_mutex_getprioceiling F
@ -2614,6 +2622,7 @@ GLIBC_2.42 pthread_rwlockattr_destroy F
GLIBC_2.42 pthread_rwlockattr_getpshared F
GLIBC_2.42 pthread_rwlockattr_init F
GLIBC_2.42 pthread_rwlockattr_setpshared F
GLIBC_2.42 pthread_setspecific F
GLIBC_2.42 uabs F
GLIBC_2.42 uimaxabs F
GLIBC_2.42 ulabs F

View File

@ -1,7 +1,6 @@
GLIBC_2.12 __mutex_lock_solid F
GLIBC_2.12 __mutex_unlock_solid F
GLIBC_2.12 __pthread_get_cleanup_stack F
GLIBC_2.12 __pthread_key_create F
GLIBC_2.12 __pthread_kill F
GLIBC_2.12 __pthread_mutex_transfer_np F
GLIBC_2.12 __pthread_spin_destroy F
@ -29,15 +28,11 @@ GLIBC_2.12 pthread_exit F
GLIBC_2.12 pthread_getattr_np F
GLIBC_2.12 pthread_getconcurrency F
GLIBC_2.12 pthread_getcpuclockid F
GLIBC_2.12 pthread_getspecific F
GLIBC_2.12 pthread_join F
GLIBC_2.12 pthread_key_create F
GLIBC_2.12 pthread_key_delete F
GLIBC_2.12 pthread_kill F
GLIBC_2.12 pthread_mutex_transfer_np F
GLIBC_2.12 pthread_setconcurrency F
GLIBC_2.12 pthread_setschedprio F
GLIBC_2.12 pthread_setspecific F
GLIBC_2.12 pthread_spin_destroy F
GLIBC_2.12 pthread_spin_init F
GLIBC_2.12 pthread_spin_lock F

View File

@ -392,6 +392,7 @@ GLIBC_2.38 __profile_frequency F
GLIBC_2.38 __progname D 0x8
GLIBC_2.38 __progname_full D 0x8
GLIBC_2.38 __pthread_get_cleanup_stack F
GLIBC_2.38 __pthread_key_create F
GLIBC_2.38 __pthread_self F
GLIBC_2.38 __ptsname_r_chk F
GLIBC_2.38 __pwrite64 F
@ -1554,6 +1555,9 @@ GLIBC_2.38 pthread_condattr_setpshared F
GLIBC_2.38 pthread_equal F
GLIBC_2.38 pthread_exit F
GLIBC_2.38 pthread_getschedparam F
GLIBC_2.38 pthread_getspecific F
GLIBC_2.38 pthread_key_create F
GLIBC_2.38 pthread_key_delete F
GLIBC_2.38 pthread_mutex_clocklock F
GLIBC_2.38 pthread_mutex_consistent F
GLIBC_2.38 pthread_mutex_consistent_np F
@ -1599,6 +1603,7 @@ GLIBC_2.38 pthread_self F
GLIBC_2.38 pthread_setcancelstate F
GLIBC_2.38 pthread_setcanceltype F
GLIBC_2.38 pthread_setschedparam F
GLIBC_2.38 pthread_setspecific F
GLIBC_2.38 pthread_sigmask F
GLIBC_2.38 ptrace F
GLIBC_2.38 ptsname F
@ -2276,6 +2281,9 @@ GLIBC_2.42 pthread_barrierattr_destroy F
GLIBC_2.42 pthread_barrierattr_getpshared F
GLIBC_2.42 pthread_barrierattr_init F
GLIBC_2.42 pthread_barrierattr_setpshared F
GLIBC_2.42 pthread_getspecific F
GLIBC_2.42 pthread_key_create F
GLIBC_2.42 pthread_key_delete F
GLIBC_2.42 pthread_mutex_consistent F
GLIBC_2.42 pthread_mutex_consistent_np F
GLIBC_2.42 pthread_mutex_getprioceiling F
@ -2297,6 +2305,7 @@ GLIBC_2.42 pthread_rwlockattr_destroy F
GLIBC_2.42 pthread_rwlockattr_getpshared F
GLIBC_2.42 pthread_rwlockattr_init F
GLIBC_2.42 pthread_rwlockattr_setpshared F
GLIBC_2.42 pthread_setspecific F
GLIBC_2.42 uabs F
GLIBC_2.42 uimaxabs F
GLIBC_2.42 ulabs F

View File

@ -6,7 +6,6 @@ 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_get_cleanup_stack F
GLIBC_2.38 __pthread_key_create F
GLIBC_2.38 __pthread_kill F
GLIBC_2.38 __pthread_mutex_transfer_np F
GLIBC_2.38 __pthread_spin_destroy F
@ -47,17 +46,13 @@ GLIBC_2.38 pthread_exit F
GLIBC_2.38 pthread_getattr_np F
GLIBC_2.38 pthread_getconcurrency F
GLIBC_2.38 pthread_getcpuclockid F
GLIBC_2.38 pthread_getspecific F
GLIBC_2.38 pthread_hurd_cond_timedwait_np F
GLIBC_2.38 pthread_hurd_cond_wait_np F
GLIBC_2.38 pthread_join F
GLIBC_2.38 pthread_key_create F
GLIBC_2.38 pthread_key_delete F
GLIBC_2.38 pthread_kill F
GLIBC_2.38 pthread_mutex_transfer_np F
GLIBC_2.38 pthread_setconcurrency F
GLIBC_2.38 pthread_setschedprio F
GLIBC_2.38 pthread_setspecific F
GLIBC_2.38 pthread_spin_destroy F
GLIBC_2.38 pthread_spin_init F
GLIBC_2.38 pthread_spin_lock F