summaryrefslogtreecommitdiff
path: root/include/netdb.h
diff options
context:
space:
mode:
authorAustin Foxley <austinf@cetoncorp.com>2009-09-19 09:54:20 -0700
committerAustin Foxley <austinf@cetoncorp.com>2009-09-26 09:26:28 -0700
commitd21497f9fba95688e464ae712bd6b4c0fbc4ea13 (patch)
treec6fb7dbd153266214843d5057672b49a22fc10d2 /include/netdb.h
parent18cc8e0e459edf5391016ef76a4ff3108981d86a (diff)
include/: add tls errno and res_state
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
Diffstat (limited to 'include/netdb.h')
-rw-r--r--include/netdb.h36
1 files changed, 26 insertions, 10 deletions
diff --git a/include/netdb.h b/include/netdb.h
index 99e02f050..9d3807d3a 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -54,21 +54,38 @@
__BEGIN_DECLS
/* Error status for non-reentrant lookup functions.
- We use a macro to access always the thread-specific `h_errno' variable.
- We always need the extern int here in case internal libc code undefines
- the macro because it needs access to the underlying storage. */
-extern int h_errno;
-#ifdef __UCLIBC_HAS_THREADS__
-# define h_errno (*__h_errno_location ())
-#endif
+ We use a macro to access always the thread-specific `h_errno' variable. */
+#define h_errno (*__h_errno_location ())
/* Function to get address of global `h_errno' variable. */
extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
libc_hidden_proto(__h_errno_location)
+/* 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_TLS__ \
+ && (!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_TLS__ */
+# 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. */
@@ -101,7 +118,6 @@ libc_hidden_proto(herror)
extern __const char *hstrerror (int __err_num) __THROW;
-
/* Description of data base entry for a single host. */
struct hostent
{