summaryrefslogtreecommitdiff
path: root/src/errno/__errno.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/errno/__errno.c')
-rw-r--r--src/errno/__errno.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/errno/__errno.c b/src/errno/__errno.c
index 99061185..b3016d32 100644
--- a/src/errno/__errno.c
+++ b/src/errno/__errno.c
@@ -1,8 +1,17 @@
#include <errno.h>
-#include "../_nonstd.h"
+#include "../_perthread.h"
+
+/*
+This version of __errno() is for single-threaded programs and those compiled
+with _Thread_local support from C11 or later.
+
+For programs that require per-thread errno without language support (i.e.
+using pthreads), there is an identically signatured version of this function
+in ../pthread/__pt_errno.c which uses pthread keys.
+*/
int *__errno(void)
{
- return __libc(ERRNO);
+ THREAD_LOCAL int e = 0;
+ return &e;
}
-