[uClibc-cvs] svn commit: branches/uClibc-nptl: include libc/inet
sjhill at uclibc.org
sjhill at uclibc.org
Fri Jun 3 03:19:49 UTC 2005
Author: sjhill
Date: 2005-06-02 21:19:48 -0600 (Thu, 02 Jun 2005)
New Revision: 10465
Log:
Update structures and defines necessary to make resolver code thread
safe for TLS and NPTL. Our name resolver code is so out of date, we
made not be able to correctly utilize it in multi-threaded programs
compiled with NPTL.
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-06-03 03:15:13 UTC (rev 10464)
+++ branches/uClibc-nptl/include/resolv.h 2005-06-03 03:19:48 UTC (rev 10465)
@@ -217,7 +217,25 @@
/* 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
Modified: branches/uClibc-nptl/libc/inet/resolv.c
===================================================================
--- branches/uClibc-nptl/libc/inet/resolv.c 2005-06-03 03:15:13 UTC (rev 10464)
+++ branches/uClibc-nptl/libc/inet/resolv.c 2005-06-03 03:19:48 UTC (rev 10465)
@@ -1149,9 +1149,34 @@
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
More information about the uClibc-cvs
mailing list