summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/features.h29
-rw-r--r--include/netdb.h2
-rw-r--r--include/resolv.h140
-rw-r--r--include/stdlib.h2
-rw-r--r--ldso/include/ldsodefs.h7
-rw-r--r--libc/inet/resolv.c32
-rw-r--r--libc/misc/internals/errno.c13
7 files changed, 105 insertions, 120 deletions
diff --git a/include/features.h b/include/features.h
index 07d19f1f5..339a320ba 100644
--- a/include/features.h
+++ b/include/features.h
@@ -106,6 +106,19 @@
#undef __FAVOR_BSD
#undef __KERNEL_STRICT_NAMES
+/*
+ * NPTL requires this to be defined. Unfortunately, due to complexities
+ * in include dependencies, this cannot be defined on a per file basis.
+ */
+#define __need_uClibc_config_h
+#include <bits/uClibc_config.h>
+#ifdef __PTHREADS_NATIVE__
+# ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+# endif
+#endif
+#undef __need_uClibc_config_h
+
/* Suppress kernel-name space pollution unless user expressedly asks
for it. */
#ifndef _LOOSE_KERNEL_NAMES
@@ -280,14 +293,6 @@
# define __GLIBC_MINOR__ 2
#endif
-/*
- * NPTL requires this to be defined. Unfortunately, due to complexities
- * in include dependencies, this cannot be defined on a per file basis.
- */
-#ifdef __PTHREADS_NATIVE__
-# define __USE_XOPEN2K 1
-#endif
-
/* Convenience macros to test the versions of glibc and gcc.
Use them like this:
#if __GNUC_PREREQ (2,8)
@@ -362,7 +367,7 @@ uClibc was built without large file support enabled.
/* Some nice features only work properly with ELF */
#if defined _LIBC
-#if defined __HAVE_ELF__
+# if defined __HAVE_ELF__
/* Define ALIASNAME as a weak alias for NAME. */
# define weak_alias(name, aliasname) _weak_alias (name, aliasname)
# define _weak_alias(name, aliasname) \
@@ -384,8 +389,8 @@ uClibc was built without large file support enabled.
asm (".section " ".gnu.warning." #symbol "\n\t.previous"); \
static const char __evoke_link_warning_##symbol[] \
__attribute__ ((unused, section (".gnu.warning." #symbol "\n\t#"))) = msg;
-#endif
-#else /* !defined __HAVE_ELF__ */
+# endif
+# else /* !defined __HAVE_ELF__ */
# define strong_alias(name, aliasname) _strong_alias (name, aliasname)
# define weak_alias(name, aliasname) _strong_alias (name, aliasname)
# define _strong_alias(name, aliasname) \
@@ -394,7 +399,7 @@ uClibc was built without large file support enabled.
# define link_warning(symbol, msg) \
asm (".stabs \"" msg "\",30,0,0,0\n\t" \
".stabs \"" #symbol "\",1,0,0,0\n");
-#endif
+# endif
#ifndef weak_function
/* If we do not have the __attribute__ ((weak)) syntax, there is no way we
diff --git a/include/netdb.h b/include/netdb.h
index c047c7fe7..1bea76efc 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -53,8 +53,8 @@
__BEGIN_DECLS
+#ifdef __PTHREADS_NATIVE__
#include <tls.h>
-#ifdef USE___THREAD
extern __thread int h_errno attribute_tls_model_ie;
#else
/* Error status for non-reentrant lookup functions. */
diff --git a/include/resolv.h b/include/resolv.h
index e94247f91..940f1ae0a 100644
--- a/include/resolv.h
+++ b/include/resolv.h
@@ -50,41 +50,26 @@
*/
#ifndef _RESOLV_H_
-#define _RESOLV_H_
-#include <sys/param.h>
#if (!defined(BSD)) || (BSD < 199306)
# include <sys/bitypes.h>
#else
# include <sys/types.h>
#endif
-#include <sys/cdefs.h>
#include <stdio.h>
-
#include <netinet/in.h>
-#include <arpa/nameser.h>
-
-/*
- * Revision information. This is the release date in YYYYMMDD format.
- * It can change every day so the right thing to do with it is use it
- * in preprocessor commands such as "#if (__RES > 19931104)". Do not
- * compare for equality; rather, use it to determine whether your resolver
- * is new enough to contain a certain feature.
- */
-
-/* #define __RES 19991006 we don't have a new resolver yet */
-#define __RES 19960801
-/*
- * Resolver configuration file.
- * Normally not present, but may contain the address of the
- * inital name server(s) to query and the domain search list.
- */
+#ifndef __need_res_state
+#define _RESOLV_H_
-#ifndef _PATH_RESCONF
-#define _PATH_RESCONF "/etc/resolv.conf"
+#include <sys/param.h>
+#include <sys/cdefs.h>
+#include <arpa/nameser.h>
#endif
+#ifndef __res_state_defined
+# define __res_state_defined
+
typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
res_sendhookact;
@@ -109,6 +94,30 @@ struct res_sym {
};
/*
+ * Resolver options (keep these in synch with res_debug.c, please)
+ */
+#define RES_INIT 0x00000001 /* address initialized */
+#define RES_DEBUG 0x00000002 /* print debug messages */
+#define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/
+#define RES_USEVC 0x00000008 /* use virtual circuit */
+#define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */
+#define RES_IGNTC 0x00000020 /* ignore trucation errors */
+#define RES_RECURSE 0x00000040 /* recursion desired */
+#define RES_DEFNAMES 0x00000080 /* use default domain name */
+#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */
+#define RES_DNSRCH 0x00000200 /* search up local domain tree */
+#define RES_INSECURE1 0x00000400 /* type 1 security disabled */
+#define RES_INSECURE2 0x00000800 /* type 2 security disabled */
+#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
+#define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */
+#define RES_ROTATE 0x00004000 /* rotate ns list after each query */
+#define RES_NOCHECKNAME 0x00008000 /* do not check names for sanity. */
+#define RES_KEEPTSIG 0x00010000 /* do not strip TSIG records */
+#define RES_BLAST 0x00020000 /* blast all recursive servers */
+
+#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
+
+/*
* Global defines and variables for resolver stub.
*/
#define MAXNS 3 /* max # name servers we'll track */
@@ -162,6 +171,35 @@ struct __res_state {
};
typedef struct __res_state *res_state;
+# undef __need_res_state
+#endif /* ! __res_state_defined */
+
+#endif /* ! _RESOLV_H_ */
+
+
+#ifdef _RESOLV_H_
+/*
+ * Revision information. This is the release date in YYYYMMDD format.
+ * It can change every day so the right thing to do with it is use it
+ * in preprocessor commands such as "#if (__RES > 19931104)". Do not
+ * compare for equality; rather, use it to determine whether your resolver
+ * is new enough to contain a certain feature.
+ */
+
+/* #define __RES 19991006 we don't have a new resolver yet */
+#define __RES 19960801
+
+/*
+ * Resolver configuration file.
+ * Normally not present, but may contain the address of the
+ * inital name server(s) to query and the domain search list.
+ */
+
+#ifndef _PATH_RESCONF
+#define _PATH_RESCONF "/etc/resolv.conf"
+#endif
+
+
/*
* Resolver flags (used to be discrete per-module statics ints).
@@ -173,30 +211,6 @@ typedef struct __res_state *res_state;
#define RES_EXHAUSTIVE 0x00000001 /* always do all queries */
/*
- * Resolver options (keep these in synch with res_debug.c, please)
- */
-#define RES_INIT 0x00000001 /* address initialized */
-#define RES_DEBUG 0x00000002 /* print debug messages */
-#define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/
-#define RES_USEVC 0x00000008 /* use virtual circuit */
-#define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */
-#define RES_IGNTC 0x00000020 /* ignore trucation errors */
-#define RES_RECURSE 0x00000040 /* recursion desired */
-#define RES_DEFNAMES 0x00000080 /* use default domain name */
-#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */
-#define RES_DNSRCH 0x00000200 /* search up local domain tree */
-#define RES_INSECURE1 0x00000400 /* type 1 security disabled */
-#define RES_INSECURE2 0x00000800 /* type 2 security disabled */
-#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
-#define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */
-#define RES_ROTATE 0x00004000 /* rotate ns list after each query */
-#define RES_NOCHECKNAME 0x00008000 /* do not check names for sanity. */
-#define RES_KEEPTSIG 0x00010000 /* do not strip TSIG records */
-#define RES_BLAST 0x00020000 /* blast all recursive servers */
-
-#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
-
-/*
* Resolver "pfcode" values. Used by dig.
*/
#define RES_PRF_STATS 0x00000001
@@ -216,27 +230,6 @@ typedef struct __res_state *res_state;
#define RES_PRF_INIT 0x00004000
/* 0x00008000 */
-/* Internal (static) resolver context. */
-/*
- * NPTL - This code was taken from 'include/resolve.h'
- * and makes the assumption that our libraries
- * are reentrant.
- */
-#ifdef IS_IN_libpthread
-#include <libc-symbols.h>
-#include <tls.h>
-#if USE___THREAD
-# 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
-extern struct __res_state _res;
-#endif
-
#ifndef __BIND_NOSTATIC
#define fp_nquery __fp_nquery
@@ -388,4 +381,13 @@ int res_nsend __P((res_state, const u_char *, int, u_char *, int));
void res_nclose __P((res_state));
__END_DECLS
-#endif /* !_RESOLV_H_ */
+#endif /* _RESOLV_H_ */
+
+/* Internal (static) resolver context. */
+#ifdef __PTHREADS_NATIVE__
+#include <tls.h>
+# define _res (*__resp)
+extern __thread struct __res_state *__resp attribute_tls_model_ie;
+#else
+extern struct __res_state _res;
+#endif
diff --git a/include/stdlib.h b/include/stdlib.h
index eaeb7a104..2e437d3fc 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -491,7 +491,7 @@ extern void *valloc (size_t __size) __THROW __attribute_malloc__;
#ifdef __USE_XOPEN2K
/* Allocate memory of SIZE bytes with an alignment of ALIGNMENT. */
extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
- __THROW __attribute_malloc__;
+ __THROW;
#endif
__BEGIN_NAMESPACE_STD
diff --git a/ldso/include/ldsodefs.h b/ldso/include/ldsodefs.h
index 06b5f3729..833fe2c25 100644
--- a/ldso/include/ldsodefs.h
+++ b/ldso/include/ldsodefs.h
@@ -12,16 +12,13 @@
#define GL(x) _##x
#define GLRO(x) _##x
-/*
- * NPTL - This was taken from 'sysdeps/generic/ldsodefs.h'. It is
- * used for backtrace capability.
- */
/* Variable pointing to the end of the stack (or close to it). This value
must be constant over the runtime of the application. Some programs
might use the variable which results in copy relocations on some
platforms. But this does not matter, ld.so can always use the local
copy. */
-extern void *__libc_stack_end attribute_relro;
+//extern void *__libc_stack_end attribute_relro;
+extern void *__libc_stack_end;
rtld_hidden_proto (__libc_stack_end)
/* Determine next available module ID. */
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 695ee048b..798a3f5d4 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -1096,7 +1096,13 @@ struct hostent *gethostbyname2(const char *name, int family)
#ifdef L_res_init
+#ifdef __PTHREADS_NATIVE__
+#include <tls.h>
+struct __res_state _res_thread;
+__thread struct __res_state *__resp = &_res_thread;
+#else
struct __res_state _res;
+#endif
int res_init(void)
{
@@ -1149,34 +1155,8 @@ void res_close( void )
return;
}
-/*
- * NPTL - This code was taken from 'resolve/res_libc.c' and
- * may still be incorrect. Our name resolver code is
- * so out of date, we made not be able to correctly
- * utilize it in multi-threaded programs.
- */
-#ifdef IS_IN_libpthread
-
-/* This needs to be after the use of _res in res_init, above. */
-#undef _res
-
-/* The resolver state for use by single-threaded programs.
- This differs from plain `struct __res_state _res;' in that it doesn't
- create a common definition, but a plain symbol that resides in .bss,
- which can have an alias. */
-struct __res_state _res __attribute__((section (".bss")));
-
-#if USE___THREAD
-#undef __resp
-__thread struct __res_state *__resp = &_res;
-extern __thread struct __res_state *__libc_resp
- __attribute__ ((alias ("__resp"))) attribute_hidden;
-#endif
-#endif
-
#endif
-
#ifdef L_res_query
#ifndef MIN
diff --git a/libc/misc/internals/errno.c b/libc/misc/internals/errno.c
index f2424eae0..5197e0aec 100644
--- a/libc/misc/internals/errno.c
+++ b/libc/misc/internals/errno.c
@@ -1,14 +1,15 @@
#include <features.h>
#undef errno
+#if __PTHREADS_NATIVE__
+#include <tls.h>
extern int errno;
-extern int h_errno;
-
-#if 0
-/* Unfortunately, this doesn't work... */
-int h_errno __attribute__ ((section (".bss"))) = 0;
-int errno __attribute__ ((section (".bss"))) = 0;
+extern __thread int _h_errno;
+int _errno = 0;
+__thread int _h_errno;
#else
+extern int errno;
+extern int h_errno;
int _errno = 0;
int _h_errno = 0;
#endif