From ec31b208ab1644d98440af98eb4709ff9a729a00 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Thu, 23 Dec 2021 16:41:53 +0000 Subject: [PATCH] Implemented support for thread-local storage --- photon/libc/include/errno.h | 5 +++-- photon/libc/sys/horizon/machine/x86_64/pthread.s | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 photon/libc/sys/horizon/machine/x86_64/pthread.s diff --git a/photon/libc/include/errno.h b/photon/libc/include/errno.h index b50e308..9dae652 100644 --- a/photon/libc/include/errno.h +++ b/photon/libc/include/errno.h @@ -3,13 +3,14 @@ #include -#define errno (*__errno_location()) +#define errno (__get_errno()) #if defined(__cplusplus) extern "C" { #endif -extern int *__errno_location(void); +extern void __set_errno(int v); +extern int __get_errno(void); #if defined(__cplusplus) } diff --git a/photon/libc/sys/horizon/machine/x86_64/pthread.s b/photon/libc/sys/horizon/machine/x86_64/pthread.s new file mode 100644 index 0000000..5dfb86f --- /dev/null +++ b/photon/libc/sys/horizon/machine/x86_64/pthread.s @@ -0,0 +1,11 @@ +.global pthread_self +.type pthread_self, @function + +pthread_self: + push %rbp + mov %rsp, %rbp + + mov %fs:0, %rax + + pop %rbp + ret