summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc/misc/internals/errno.c13
-rw-r--r--libc/misc/internals/internal_errno.h3
2 files changed, 15 insertions, 1 deletions
diff --git a/libc/misc/internals/errno.c b/libc/misc/internals/errno.c
index 029fdcfde..e1b5d7e84 100644
--- a/libc/misc/internals/errno.c
+++ b/libc/misc/internals/errno.c
@@ -1,5 +1,15 @@
-#include "internal_errno.h"
+#include <features.h>
+
+#ifdef __UCLIBC_HAS_TLS__
+__thread int errno;
+__thread int h_errno;
+
+extern __thread int __libc_errno __attribute__ ((alias ("errno")));
+extern __thread int __libc_h_errno __attribute__ ((alias ("h_errno")));
+#define h_errno __libc_h_errno
+#else
+#include "internal_errno.h"
int errno = 0;
int h_errno = 0;
@@ -9,3 +19,4 @@ weak_alias(errno, _errno)
libc_hidden_def(h_errno)
weak_alias(h_errno, _h_errno)
#endif
+#endif
diff --git a/libc/misc/internals/internal_errno.h b/libc/misc/internals/internal_errno.h
index a93d0bf02..b49198579 100644
--- a/libc/misc/internals/internal_errno.h
+++ b/libc/misc/internals/internal_errno.h
@@ -6,6 +6,8 @@
#include <errno.h>
#include <netdb.h>
+#ifndef __UCLIBC_HAS_TLS__
+
#undef errno
#undef h_errno
@@ -16,3 +18,4 @@ extern int errno;
libc_hidden_proto(h_errno)
libc_hidden_proto(errno)
#endif
+#endif