LibC: Make pthread_t pointer to uthread instead of a thread id

This will allow getting info about other threads in userspace!
This commit is contained in:
2026-07-02 19:29:19 +03:00
parent f449ca8161
commit b19b7f064a
8 changed files with 106 additions and 94 deletions

View File

@@ -7,10 +7,7 @@
__BEGIN_DECLS
#define __need_pid_t
#include <sys/types.h>
typedef pid_t pthread_t;
typedef struct uthread* pthread_t;
__END_DECLS

View File

@@ -5,9 +5,11 @@
__BEGIN_DECLS
#define __need_pid_t
#define __need_size_t
#include <sys/types.h>
#include <bits/types/pthread_attr_t.h>
#include <bits/types/pthread_key_t.h>
#include <bits/types/pthread_t.h>
#include <limits.h>
@@ -36,18 +38,24 @@ typedef struct _dynamic_tls_t
struct uthread
{
struct uthread* self;
// TLS
void* master_tls_addr;
size_t master_tls_size;
size_t master_tls_module_count;
_dynamic_tls_t* dynamic_tls;
_pthread_cleanup_t* cleanup_stack;
pthread_t id;
// LIBC
pid_t id;
pthread_attr_t attr;
int errno_;
int cancel_type;
int cancel_state;
volatile int canceled;
_pthread_cleanup_t* cleanup_funcs;
pthread_key_t specific_keys[PTHREAD_KEYS_MAX];
void* specific_values[PTHREAD_KEYS_MAX];
void* specific_vals[PTHREAD_KEYS_MAX];
// FIXME: make this dynamic
uintptr_t dtv[1 + 256];
};