[uClibc-cvs] svn commit: branches/uClibc-nptl: include libc/inet
sjhill at uclibc.org
sjhill at uclibc.org
Fri Aug 12 11:18:24 UTC 2005
Author: sjhill
Date: 2005-08-12 05:18:23 -0600 (Fri, 12 Aug 2005)
New Revision: 11121
Log:
This will hopefully be the last modification to the resolver code for a while. The complexity comes from the code used only during library build time, to non-threaded programs to threaded programs such that things are not a mess. I was getting undefined '_res' when doing a buildroot, but things are fixed now. This is much cleaner and more sane.
Modified:
branches/uClibc-nptl/include/resolv.h
branches/uClibc-nptl/libc/inet/resolv.c
Changeset:
Modified: branches/uClibc-nptl/include/resolv.h
===================================================================
--- branches/uClibc-nptl/include/resolv.h 2005-08-12 06:08:41 UTC (rev 11120)
+++ branches/uClibc-nptl/include/resolv.h 2005-08-12 11:18:23 UTC (rev 11121)
@@ -230,6 +230,12 @@
#define RES_PRF_INIT 0x00004000
/* 0x00008000 */
+/* Things involving an internal (static) resolver context. */
+__BEGIN_DECLS
+extern struct __res_state *__res_state(void) __attribute__ ((__const__));
+__END_DECLS
+#define _res (*__res_state())
+
#ifndef __BIND_NOSTATIC
#define fp_nquery __fp_nquery
@@ -383,11 +389,9 @@
#endif /* _RESOLV_H_ */
-/* Internal (static) resolver context. */
-#ifdef __PTHREADS_NATIVE__
-#include <tls.h>
+#if defined(__PTHREADS_NATIVE__) && defined(IS_IN_libpthread)
+# include <tls.h>
+# undef _res
# define _res (*__resp)
extern __thread struct __res_state *__resp attribute_tls_model_ie;
-#else
-extern struct __res_state _res;
#endif
Modified: branches/uClibc-nptl/libc/inet/resolv.c
===================================================================
--- branches/uClibc-nptl/libc/inet/resolv.c 2005-08-12 06:08:41 UTC (rev 11120)
+++ branches/uClibc-nptl/libc/inet/resolv.c 2005-08-12 11:18:23 UTC (rev 11121)
@@ -1096,17 +1096,22 @@
#ifdef L_res_init
+#undef _res
+struct __res_state _res;
+
+struct __res_state * weak_const_function __res_state (void)
+{
+ return &_res;
+}
+
#ifdef __PTHREADS_NATIVE__
#include <tls.h>
-struct __res_state _res_thread;
-__thread struct __res_state *__resp = &_res_thread;
-#else
-struct __res_state _res;
+__thread struct __res_state *__resp = &_res;
#endif
int res_init(void)
{
- struct __res_state *rp = &(_res);
+ struct __res_state *rp = __res_state();
__close_nameservers();
__open_nameservers();
More information about the uClibc-cvs
mailing list