diff options
author | Itamar <itamar8910@gmail.com> | 2020-10-10 17:48:27 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-14 23:05:53 +0100 |
commit | 781aa424a9b34917ad4abb1753d7cf7809dea7be (patch) | |
tree | f42bbf620e9a816c5242afdf59576d77c0fce79d | |
parent | 65ee2f07b725e8e71c156de8a8741e8e545c8786 (diff) | |
download | serenity-781aa424a9b34917ad4abb1753d7cf7809dea7be.zip |
LibC: Add NO_TLS preprocessor flag
When this flag is defined, LibC does not use TLS.
It will be useful for the dynamic loader.
-rw-r--r-- | Libraries/LibC/errno.h | 5 | ||||
-rw-r--r-- | Libraries/LibC/libcinit.cpp | 4 | ||||
-rw-r--r-- | Libraries/LibC/unistd.cpp | 5 |
3 files changed, 14 insertions, 0 deletions
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) |