htl: move __pthread_init_{specific, static_tls}, __pthread_{alloc}, dealloc} into libc.

Message-ID: <20250815181500.107433-4-gfleury@disroot.org>
This commit is contained in:
gfleury 2025-08-15 20:14:44 +02:00 committed by Samuel Thibault
parent b586357e2a
commit 2522a3f3ae
7 changed files with 23 additions and 5 deletions

View File

@ -25,11 +25,8 @@ SYSDEPS := lockfile
LCLHDRS :=
libpthread-routines := \
pt-init-specific \
pt-alloc \
pt-create \
pt-getattr \
pt-dealloc \
pt-detach \
pt-exit \
pt-initialize \
@ -108,6 +105,7 @@ routines := \
forward \
htlfreeres \
libc_pthread_init \
pt-alloc \
pt-attr \
pt-attr-destroy \
pt-attr-getdetachstate \
@ -153,10 +151,12 @@ routines := \
pt-condattr-init \
pt-condattr-setclock \
pt-condattr-setpshared \
pt-dealloc \
pt-destroy-specific \
pt-getconcurrency \
pt-getschedparam \
pt-getspecific \
pt-init-specific \
pt-key-create \
pt-key-delete \
pt-mutex-checklocked \

View File

@ -201,9 +201,11 @@ libc {
__pthread_cleanup_stack;
__pthread_total;
___pthread_self;
__pthread_alloc;
__pthread_block;
__pthread_block_intr;
__pthread_init_thread;
__pthread_init_static_tls;
__pthread_default_attr;
__pthread_attr_init;
__pthread_attr_getstacksize;
@ -212,6 +214,8 @@ libc {
__pthread_attr_setstacksize;
__pthread_attr_setstackaddr;
__pthread_attr_setstack;
__pthread_dealloc;
__pthread_dealloc_finish;
__pthread_setcancelstate;
__pthread_cond_broadcast;
__pthread_cond_destroy;
@ -225,6 +229,7 @@ libc {
__pthread_destroy_specific;
__pthread_getspecific;
__pthread_key_delete;
__pthread_max_threads;
__pthread_mutex_checklocked;
__pthread_mutex_destroy;
__pthread_mutex_init;

View File

@ -23,6 +23,7 @@
#include <string.h>
#include <pt-internal.h>
#include <ldsodefs.h>
/* This braindamage is necessary because the standard says that some
of the threads functions "shall fail" if "No thread could be found
@ -30,6 +31,7 @@
/* The size of the thread ID lookup table. */
int __pthread_max_threads;
libc_hidden_data_def (__pthread_max_threads)
/* List of thread structures corresponding to free thread IDs. */
struct __pthread *__pthread_free_threads;
@ -201,6 +203,7 @@ retry:
*pthread = new;
return 0;
}
libc_hidden_def (__pthread_alloc)
void
attribute_hidden
@ -230,3 +233,4 @@ __pthread_init_static_tls (struct link_map *map)
}
__libc_rwlock_unlock (GL (dl_pthread_threads_lock));
}
libc_hidden_def (__pthread_init_static_tls)

View File

@ -23,6 +23,7 @@
#include <pt-internal.h>
#include <atomic.h>
#include <ldsodefs.h>
/* List of thread structures corresponding to free thread IDs. */
extern struct __pthread *__pthread_free_threads;
@ -55,6 +56,7 @@ __pthread_dealloc (struct __pthread *pthread)
__pthread_enqueue (&__pthread_free_threads, pthread);
__pthread_mutex_unlock (&__pthread_free_threads_lock);
}
libc_hidden_def (__pthread_dealloc)
/* Confirm deallocation of the thread structure for PTHREAD. */
void
@ -69,3 +71,4 @@ __pthread_dealloc_finish (struct __pthread *pthread)
which reads this variable. */
pthread->terminated = TRUE;
}
libc_hidden_def (__pthread_dealloc_finish)

View File

@ -172,6 +172,7 @@ extern int __pthread_concurrency;
/* The size of the thread ID lookup table. */
extern int __pthread_max_threads;
libc_hidden_proto (__pthread_max_threads)
#define __pthread_getid(thread) \
({ struct __pthread *__t = NULL; \
@ -209,6 +210,7 @@ extern int __pthread_create_internal (struct __pthread **__restrict pthread,
/* Allocate a new thread structure and a pthread thread ID (but not a
kernel thread or a stack). THREAD has one reference. */
extern int __pthread_alloc (struct __pthread **thread);
libc_hidden_proto (__pthread_alloc)
/* Deallocate the content of the thread structure. This is the dual of
__pthread_alloc (N.B. it does not call __pthread_stack_dealloc nor
@ -217,11 +219,12 @@ extern int __pthread_alloc (struct __pthread **thread);
to call __pthread_dealloc_finish when it is really finished with using
THREAD. */
extern void __pthread_dealloc (struct __pthread *thread);
libc_hidden_proto (__pthread_dealloc)
/* Confirm deallocating the thread structure. Before calling this
the structure will not be reused yet. */
extern void __pthread_dealloc_finish (struct __pthread *pthread);
libc_hidden_proto (__pthread_dealloc_finish)
/* Allocate a stack of size STACKSIZE. The stack base shall be
returned in *STACKADDR. */

View File

@ -20,6 +20,8 @@
#include <stdlib.h>
#include <pt-internal.h>
#include <string.h>
error_t
__pthread_init_specific (struct __pthread *thread)

View File

@ -28,7 +28,8 @@
/* 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;
extern void __pthread_init_static_tls (struct link_map *);
libc_hidden_proto (__pthread_init_static_tls)
/* These represent the interface used by glibc itself. */