LibC: Move pthread keys to TCB

This removes all TLS relocations from libc which may become handy ;)
This commit is contained in:
2026-05-17 00:28:03 +03:00
parent 9e6fa0a1ba
commit ff75c15ba3
7 changed files with 41 additions and 17 deletions

View File

@@ -0,0 +1,14 @@
#ifndef _BITS_TYPES_PTHREAD_KEY_H
#define _BITS_TYPES_PTHREAD_KEY_H 1
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/pthread.h.html
#include <sys/cdefs.h>
__BEGIN_DECLS
typedef unsigned pthread_key_t;
__END_DECLS
#endif

View File

@@ -8,14 +8,13 @@
__BEGIN_DECLS
#include <bits/types/pthread_attr_t.h>
#include <bits/types/pthread_key_t.h>
#include <bits/types/pthread_t.h>
#include <stdint.h>
typedef int pthread_once_t;
typedef unsigned pthread_key_t;
typedef pthread_t pthread_spinlock_t;
typedef struct

View File

@@ -8,7 +8,9 @@ __BEGIN_DECLS
#define __need_size_t
#include <sys/types.h>
#include <bits/types/pthread_key_t.h>
#include <bits/types/pthread_t.h>
#include <limits.h>
#include <stdint.h>
typedef struct _pthread_cleanup_t
@@ -44,6 +46,8 @@ struct uthread
int cancel_type;
int cancel_state;
volatile int canceled;
pthread_key_t specific_keys[PTHREAD_KEYS_MAX];
void* specific_values[PTHREAD_KEYS_MAX];
// FIXME: make this dynamic
uintptr_t dtv[1 + 256];
};