From 781aa424a9b34917ad4abb1753d7cf7809dea7be Mon Sep 17 00:00:00 2001 From: Itamar Date: Sat, 10 Oct 2020 17:48:27 +0300 Subject: LibC: Add NO_TLS preprocessor flag When this flag is defined, LibC does not use TLS. It will be useful for the dynamic loader. --- Libraries/LibC/errno.h | 5 +++++ Libraries/LibC/libcinit.cpp | 4 ++++ Libraries/LibC/unistd.cpp | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/Libraries/LibC/errno.h b/Libraries/LibC/errno.h index 2d2a0b334f..f763dbc914 100644 --- a/Libraries/LibC/errno.h +++ b/Libraries/LibC/errno.h @@ -43,7 +43,12 @@ __BEGIN_DECLS extern const char* const sys_errlist[]; extern int sys_nerr; + +#ifdef NO_TLS +extern int errno; +#else extern __thread int errno; +#endif #define errno errno diff --git a/Libraries/LibC/libcinit.cpp b/Libraries/LibC/libcinit.cpp index 7e38ebc36f..83209b9ca4 100644 --- a/Libraries/LibC/libcinit.cpp +++ b/Libraries/LibC/libcinit.cpp @@ -31,7 +31,11 @@ extern "C" { +#ifdef NO_TLS +int errno; +#else __thread int errno; +#endif char** environ; bool __environ_is_malloced; bool __stdio_is_initialized; diff --git a/Libraries/LibC/unistd.cpp b/Libraries/LibC/unistd.cpp index cf6643e736..da88bef354 100644 --- a/Libraries/LibC/unistd.cpp +++ b/Libraries/LibC/unistd.cpp @@ -48,7 +48,12 @@ extern "C" { +#ifdef NO_TLS +static int s_cached_tid = 0; +#else static __thread int s_cached_tid = 0; +#endif + static int s_cached_pid = 0; int chown(const char* pathname, uid_t uid, gid_t gid) -- cgit v1.2.3