From 1e04052f49c8fa26213de2a0a7e9d43ad873d5a1 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Wed, 12 Aug 2020 13:26:50 -0400 Subject: migrate __errno() to using _perthread.h macros --- src/errno/__errno.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/errno') 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 -#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; } - -- cgit v1.2.1