summaryrefslogtreecommitdiffstats
path: root/include/netdb.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/netdb.h')
-rw-r--r--include/netdb.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/include/netdb.h b/include/netdb.h
index 1d27ddcd4..d386736e1 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -60,9 +60,31 @@ __BEGIN_DECLS
/* Function to get address of global `h_errno' variable. */
extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
+/* Macros for accessing h_errno from inside libc. */
#ifdef _LIBC
-# define __set_h_errno(x) (h_errno = (x))
-#endif
+# ifdef __UCLIBC_HAS_THREADS__
+# if defined __UCLIBC_HAS_THREADS_NATIVE__ \
+ && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# undef h_errno
+# ifndef NOT_IN_libc
+# define h_errno __libc_h_errno
+# else
+# define h_errno h_errno /* For #ifndef h_errno tests. */
+# endif
+extern __thread int h_errno attribute_tls_model_ie;
+# define __set_h_errno(x) (h_errno = (x))
+# else
+static inline int __set_h_errno (int __err)
+{
+ return *__h_errno_location () = __err;
+}
+# endif /* __UCLIBC_HAS_THREADS_NATIVE__ */
+# else
+# undef h_errno
+# define __set_h_errno(x) (h_errno = (x))
+extern int h_errno;
+# endif /* __UCLIBC_HAS_THREADS__ */
+#endif /* _LIBC */
/* Possible values left in `h_errno'. */
#define NETDB_INTERNAL -1 /* See errno. */