From af14b8dc592f244bb90ff471347f7c4883f00be6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 7 Sep 2019 15:55:41 +0200 Subject: [PATCH] LibC: Make "errno" thread-specific Now that the kernel supports thread-local storage, we can declare errno with the __thread keyword, which causes it to be per-thread. This should fix all the stupid issues that happen when many threads use the same errno. :^) --- Libraries/LibC/crt0.cpp | 2 +- Libraries/LibC/errno.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/LibC/crt0.cpp b/Libraries/LibC/crt0.cpp index 82005fc9a2..9136539ae7 100644 --- a/Libraries/LibC/crt0.cpp +++ b/Libraries/LibC/crt0.cpp @@ -6,7 +6,7 @@ extern "C" { int main(int, char**); -int errno; +__thread int errno; char** environ; bool __environ_is_malloced; diff --git a/Libraries/LibC/errno.h b/Libraries/LibC/errno.h index 7ac77c5e42..68db1a0417 100644 --- a/Libraries/LibC/errno.h +++ b/Libraries/LibC/errno.h @@ -17,6 +17,6 @@ __BEGIN_DECLS extern const char* sys_errlist[]; extern int sys_nerr; -extern int errno; +extern __thread int errno; __END_DECLS