From a792bbe5db99c9b7761cafa509fd14e22672b653 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sun, 22 Mar 2026 19:09:18 +0000 Subject: [PATCH] lib: c: pthread: implement per-thread errno storage --- lib/libc/pthread/thread/errno.c | 12 ++++++++++++ lib/libc/pthread/thread/pthread.h | 1 + 2 files changed, 13 insertions(+) create mode 100644 lib/libc/pthread/thread/errno.c diff --git a/lib/libc/pthread/thread/errno.c b/lib/libc/pthread/thread/errno.c new file mode 100644 index 0000000..c1d32c5 --- /dev/null +++ b/lib/libc/pthread/thread/errno.c @@ -0,0 +1,12 @@ +#include "pthread.h" + +#include +#include +#include + +int *__errno_location(void) +{ + struct __pthread *self = pthread_self(); + kern_logf("using pthread errno %p", &self->thr_errno); + return &self->thr_errno; +} diff --git a/lib/libc/pthread/thread/pthread.h b/lib/libc/pthread/thread/pthread.h index 3854097..905ea9d 100644 --- a/lib/libc/pthread/thread/pthread.h +++ b/lib/libc/pthread/thread/pthread.h @@ -9,6 +9,7 @@ enum pthread_flags { struct __pthread { struct __pthread *thr_self; + int thr_errno; enum pthread_flags thr_flags; kern_handle_t thr_handle; void *thr_map_base;