summaryrefslogtreecommitdiff
path: root/src/errno
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-08-12 13:26:50 -0400
committerJakob Kaivo <jkk@ung.org>2020-08-12 13:26:50 -0400
commit1e04052f49c8fa26213de2a0a7e9d43ad873d5a1 (patch)
treefc2649adbad6f3f8dcfff405cc5ad840c4db4abd /src/errno
parentc53a55b6db53de6691660483e1a5d695a43ac090 (diff)
migrate __errno() to using _perthread.h macros
Diffstat (limited to 'src/errno')
-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;
}
-