summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/.gitignore9
-rw-r--r--include/errno.h20
-rw-r--r--include/libc-internal.h2
-rw-r--r--include/link.h2
-rw-r--r--include/netdb.h36
-rw-r--r--include/resolv.h24
-rw-r--r--include/time.h11
7 files changed, 79 insertions, 25 deletions
diff --git a/include/.gitignore b/include/.gitignore
index b41230418..8df009b6a 100644
--- a/include/.gitignore
+++ b/include/.gitignore
@@ -1,3 +1,11 @@
+#
+# Never ignore these
+#
+!.gitignore
+
+#
+# Generated files
+#
/bits/
/config/
@@ -9,6 +17,7 @@
/hp-timing.h
/pthread.h
/semaphore.h
+/thread_db.h
/sgidefs.h
/sys/acct.h
diff --git a/include/errno.h b/include/errno.h
index b2315b90a..85268f053 100644
--- a/include/errno.h
+++ b/include/errno.h
@@ -58,8 +58,24 @@ extern const char *program_invocation_name, *program_invocation_short_name;
__END_DECLS
-#if defined _LIBC && ( defined IS_IN_libc || defined NOT_IN_libc )
-#include <bits/uClibc_errno.h>
+#if defined _LIBC && defined __UCLIBC_HAS_TLS__
+# if !defined NOT_IN_libc || defined IS_IN_libpthread
+# undef errno
+# ifndef NOT_IN_libc
+# define errno __libc_errno
+# else
+# define errno errno /* For #ifndef errno tests. */
+# endif
+extern __thread int errno attribute_tls_model_ie;
+# endif
+#endif
+
+#ifndef __set_errno
+#define __set_errno(val) (errno = (val))
+#endif
+
+#ifndef __ASSEMBLER__
+extern int *__errno_location (void) __THROW __attribute__ ((__const__));
#endif
#endif /* _ERRNO_H */
diff --git a/include/libc-internal.h b/include/libc-internal.h
index 525444ac8..33956d8b1 100644
--- a/include/libc-internal.h
+++ b/include/libc-internal.h
@@ -27,7 +27,7 @@
# define attribute_relro
#endif
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#ifdef __UCLIBC_HAS_TLS__
# define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
#endif
diff --git a/include/link.h b/include/link.h
index 6ce15df5f..ec863c989 100644
--- a/include/link.h
+++ b/include/link.h
@@ -27,7 +27,7 @@
#include <dlfcn.h>
#endif
#include <sys/types.h>
-#if defined _LIBC && defined __UCLIBC_HAS_THREADS_NATIVE__
+#if defined _LIBC && defined __UCLIBC_HAS_TLS__
#include <tls.h>
#endif
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
{
diff --git a/include/resolv.h b/include/resolv.h
index fc2fa9b99..e0cd35db1 100644
--- a/include/resolv.h
+++ b/include/resolv.h
@@ -279,14 +279,10 @@ struct res_sym {
/* 0x00008000 */
/* Things involving an internal (static) resolver context. */
-#if 0
__BEGIN_DECLS
extern struct __res_state *__res_state(void) __attribute__ ((__const__));
__END_DECLS
#define _res (*__res_state())
-#else
-extern struct __res_state _res;
-#endif
#define fp_nquery __fp_nquery
#define fp_query __fp_query
@@ -425,6 +421,24 @@ int res_nsend (res_state, const u_char *, int, u_char *, int)
__THROW;
void res_nclose (res_state) __THROW;
__END_DECLS
-#endif
+
+# if _LIBC
+# ifdef __UCLIBC_HAS_THREADS__
+# if defined __UCLIBC_HAS_TLS__ \
+ && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# undef _res
+# ifndef NOT_IN_libc
+# define __resp __libc_resp
+# endif
+# define _res (*__resp)
+extern __thread struct __res_state *__resp attribute_tls_model_ie;
+# endif
+# else
+# undef _res
+# define _res (*__resp)
+extern struct __res_state *__resp;
+# endif /* __UCLIBC_HAS_TLS__ */
+# endif /* __UCLIBC_HAS_THREADS__ */
+# endif /* _LIBC */
#endif /* !_RESOLV_H_ */
diff --git a/include/time.h b/include/time.h
index 4f060be03..7fcdf68e6 100644
--- a/include/time.h
+++ b/include/time.h
@@ -362,10 +362,9 @@ extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
/* Set clock CLOCK_ID to value TP. */
extern int clock_settime (clockid_t __clock_id, __const struct timespec *__tp)
__THROW;
-#endif /* __UCLIBC_HAS_REALTIME__ */
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning "mjn3 FIXME: a bunch of unimplemented function prototypes."
-# if defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__
+# endif /* __UCLIBC_HAS_REALTIME__ */
+# ifdef __UCLIBC_HAS_THREADS_NATIVE__
+# if defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__
/* High-resolution sleep with the specified clock.
This function is a cancellation point and therefore not marked with
@@ -376,8 +375,8 @@ extern int clock_nanosleep (clockid_t __clock_id, int __flags,
/* Return clock ID for CPU-time clock. */
extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __THROW;
-# endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
+# endif
+# endif /* __UCLIBC_HAS_THREADS_NATIVE__ */
# if defined __UCLIBC_HAS_REALTIME__
/* Create new per-process timer using CLOCK_ID. */