[git commit future 1/1] errno, h_errno: correct them for non-TLS

Khem Raj raj.khem at gmail.com
Sat Mar 19 18:51:25 UTC 2011


commit: http://git.uclibc.org/uClibc/commit/?id=e934c55580d707710df6efc52718a8ed26775df4
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/future

Move h_errno related stuff to separate file.
Do not hide errno and h_errno for non-TLS, else it keeps being 0.
Make __[h_]errno_location weak for non-TLS.

Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
---
 include/netdb.h                          |    2 +-
 libc/misc/internals/Makefile.in          |    2 +-
 libc/misc/internals/__errno_location.c   |   10 ++++++++--
 libc/misc/internals/__h_errno_location.c |   10 ++++++++--
 libc/misc/internals/errno.c              |   19 ++++++-------------
 libc/misc/internals/h_errno.c            |   14 ++++++++++++++
 libc/misc/internals/internal_errno.h     |   21 ---------------------
 libc/sysdeps/linux/common/bits/errno.h   |    2 +-
 8 files changed, 39 insertions(+), 41 deletions(-)
 create mode 100644 libc/misc/internals/h_errno.c
 delete mode 100644 libc/misc/internals/internal_errno.h

diff --git a/include/netdb.h b/include/netdb.h
index 0bf79c0..67a16a3 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -60,7 +60,7 @@ __BEGIN_DECLS
 /* Function to get address of global `h_errno' variable.  */
 extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
 #ifdef _LIBC
-# ifndef __UCLIBC_HAS_THREADS__
+# ifndef __UCLIBC_HAS_TLS__
 extern int weak_const_function *__h_errno_location(void);
 # endif
 #endif
diff --git a/libc/misc/internals/Makefile.in b/libc/misc/internals/Makefile.in
index 354dfc9..2123bbb 100644
--- a/libc/misc/internals/Makefile.in
+++ b/libc/misc/internals/Makefile.in
@@ -7,7 +7,7 @@
 
 subdirs += libc/misc/internals
 
-CSRC := tempname.c errno.c __errno_location.c __h_errno_location.c \
+CSRC := tempname.c errno.c h_errno.c __errno_location.c __h_errno_location.c \
 	parse_config.c
 
 MISC_INTERNALS_DIR := $(top_srcdir)libc/misc/internals
diff --git a/libc/misc/internals/__errno_location.c b/libc/misc/internals/__errno_location.c
index 3409500..dec913f 100644
--- a/libc/misc/internals/__errno_location.c
+++ b/libc/misc/internals/__errno_location.c
@@ -4,10 +4,16 @@
  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  */
 
-#include "internal_errno.h"
+#include <features.h>
+#include <errno.h>
+
+#ifndef __UCLIBC_HAS_TLS__
+# undef errno
+extern int errno;
+#endif
 
 int *__errno_location(void)
 {
     return &errno;
 }
-libc_hidden_weak(__errno_location)
+libc_hidden_def(__errno_location)
diff --git a/libc/misc/internals/__h_errno_location.c b/libc/misc/internals/__h_errno_location.c
index 1136776..41353d7 100644
--- a/libc/misc/internals/__h_errno_location.c
+++ b/libc/misc/internals/__h_errno_location.c
@@ -4,10 +4,16 @@
  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  */
 
-#include "internal_errno.h"
+#include <features.h>
+#include <netdb.h>
+
+#ifndef __UCLIBC_HAS_TLS__
+# undef h_errno
+extern int h_errno;
+#endif
 
 int *__h_errno_location(void)
 {
     return &h_errno;
 }
-libc_hidden_weak(__h_errno_location)
+libc_hidden_def(__h_errno_location)
diff --git a/libc/misc/internals/errno.c b/libc/misc/internals/errno.c
index 11d19ee..d990885 100644
--- a/libc/misc/internals/errno.c
+++ b/libc/misc/internals/errno.c
@@ -1,21 +1,14 @@
 #include <features.h>
+#include <errno.h>
+#undef errno
 
 #ifdef __UCLIBC_HAS_TLS__
 __thread int errno;
-__thread int h_errno;
-
 extern __thread int __libc_errno __attribute__ ((alias ("errno"))) attribute_hidden;
-extern __thread int __libc_h_errno __attribute__ ((alias ("h_errno"))) attribute_hidden;
-#define h_errno __libc_h_errno
-
 #else
-#include "internal_errno.h"
+extern int errno;
 int errno = 0;
-int h_errno = 0;
-#ifdef __UCLIBC_HAS_THREADS__
-libc_hidden_def(errno)
-weak_alias(errno, _errno)
-libc_hidden_def(h_errno)
-weak_alias(h_errno, _h_errno)
-#endif
+# ifdef __UCLIBC_HAS_THREADS__
+strong_alias(errno,_errno)
+# endif
 #endif
diff --git a/libc/misc/internals/h_errno.c b/libc/misc/internals/h_errno.c
new file mode 100644
index 0000000..8e45750
--- /dev/null
+++ b/libc/misc/internals/h_errno.c
@@ -0,0 +1,14 @@
+#include <features.h>
+#include <netdb.h>
+#undef h_errno
+
+#ifdef __UCLIBC_HAS_TLS__
+__thread int h_errno;
+extern __thread int __libc_h_errno __attribute__ ((alias ("h_errno"))) attribute_hidden;
+#else
+extern int h_errno;
+int h_errno = 0;
+# ifdef __UCLIBC_HAS_THREADS__
+strong_alias(h_errno,_h_errno)
+# endif
+#endif
diff --git a/libc/misc/internals/internal_errno.h b/libc/misc/internals/internal_errno.h
deleted file mode 100644
index b491985..0000000
--- a/libc/misc/internals/internal_errno.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- *
- */
-
-#include <features.h>
-#include <errno.h>
-#include <netdb.h>
-
-#ifndef __UCLIBC_HAS_TLS__
-
-#undef errno
-#undef h_errno
-
-extern int h_errno;
-extern int errno;
-
-#ifdef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(h_errno)
-libc_hidden_proto(errno)
-#endif
-#endif
diff --git a/libc/sysdeps/linux/common/bits/errno.h b/libc/sysdeps/linux/common/bits/errno.h
index 459cc70..07e7470 100644
--- a/libc/sysdeps/linux/common/bits/errno.h
+++ b/libc/sysdeps/linux/common/bits/errno.h
@@ -44,7 +44,7 @@
 /* Function to get address of global `errno' variable.  */
 extern int *__errno_location (void) __THROW __attribute__ ((__const__));
 #  ifdef _LIBC
-#   ifndef __UCLIBC_HAS_THREADS__
+#   ifndef __UCLIBC_HAS_TLS__
 extern int weak_const_function *__errno_location(void);
 #   endif
 #  endif
-- 
1.7.3.4



More information about the uClibc-cvs mailing list