[Glibc-bsd-commits] r4415 - trunk/glibc-ports/patches
Petr Salinger
ps-guest at alioth.debian.org
Wed May 8 09:04:11 UTC 2013
Author: ps-guest
Date: 2013-05-08 09:04:11 +0000 (Wed, 08 May 2013)
New Revision: 4415
Added:
trunk/glibc-ports/patches/linuxthreads-TLS-THREAD.diff
Log:
enhanced linuxthreads-TLS-THREAD.diff
Added: trunk/glibc-ports/patches/linuxthreads-TLS-THREAD.diff
===================================================================
--- trunk/glibc-ports/patches/linuxthreads-TLS-THREAD.diff (rev 0)
+++ trunk/glibc-ports/patches/linuxthreads-TLS-THREAD.diff 2013-05-08 09:04:11 UTC (rev 4415)
@@ -0,0 +1,276 @@
+--- a/linuxthreads/libc-tls-loc.c
++++ b/linuxthreads/libc-tls-loc.c
+@@ -19,10 +19,9 @@
+
+ #include <tls.h>
+
+-#if USE___THREAD
+-# include <errno.h>
+-# include <netdb.h>
+-# include <resolv.h>
++#include <errno.h>
++#include <netdb.h>
++#include <resolv.h>
+
+ /* These functions have identical definitions in libc. But the versioned
+ dependencies in executables bind them to libpthread.so definitions,
+@@ -45,5 +44,3 @@
+ {
+ return __resp;
+ }
+-
+-#endif
+--- a/linuxthreads/libc-tsd.c
++++ b/linuxthreads/libc-tsd.c
+@@ -20,19 +20,6 @@
+ #include <tls.h>
+ #include <resolv.h>
+
+-#if ! USE___THREAD
+-
+-/* Special hack used to build link-time libc.so object for linking libpthread.
+- See Makefile comments near libc_pic_lite.os rule for what this is for. */
+-
+-# undef _res
+-
+-int _errno;
+-int _h_errno;
+-struct __res_state _res;
+-
+-#endif
+-
+ int
+ __res_maybe_init (res_state resp, int preinit)
+ {
+--- a/linuxthreads/pthread.c
++++ b/linuxthreads/pthread.c
+@@ -317,53 +317,6 @@
+ /* Unlike in the dynamically linked case the dynamic linker has not
+ taken care of initializing the TLS data structures. */
+ __libc_setup_tls (TLS_TCB_SIZE, TLS_TCB_ALIGN);
+-# elif !USE___THREAD
+- if (__builtin_expect (GL(dl_tls_dtv_slotinfo_list) == NULL, 0))
+- {
+- tcbhead_t *tcbp;
+-
+- /* There is no actual TLS being used, so the thread register
+- was not initialized in the dynamic linker. */
+-
+- /* We need to install special hooks so that the malloc and memalign
+- calls in _dl_tls_setup and _dl_allocate_tls won't cause full
+- malloc initialization that will try to set up its thread state. */
+-
+- extern void __libc_malloc_pthread_startup (bool first_time);
+- __libc_malloc_pthread_startup (true);
+-
+- if (__builtin_expect (_dl_tls_setup (), 0)
+- || __builtin_expect ((tcbp = _dl_allocate_tls (NULL)) == NULL, 0))
+- {
+- static const char msg[] = "\
+-cannot allocate TLS data structures for initial thread\n";
+- TEMP_FAILURE_RETRY (write_not_cancel (STDERR_FILENO,
+- msg, sizeof msg - 1));
+- abort ();
+- }
+- const char *lossage = TLS_INIT_TP (tcbp, 0);
+- if (__builtin_expect (lossage != NULL, 0))
+- {
+- static const char msg[] = "cannot set up thread-local storage: ";
+- const char nl = '\n';
+- TEMP_FAILURE_RETRY (write_not_cancel (STDERR_FILENO,
+- msg, sizeof msg - 1));
+- TEMP_FAILURE_RETRY (write_not_cancel (STDERR_FILENO,
+- lossage, strlen (lossage)));
+- TEMP_FAILURE_RETRY (write_not_cancel (STDERR_FILENO, &nl, 1));
+- }
+-
+- /* Though it was allocated with libc's malloc, that was done without
+- the user's __malloc_hook installed. A later realloc that uses
+- the hooks might not work with that block from the plain malloc.
+- So we record this block as unfreeable just as the dynamic linker
+- does when it allocates the DTV before the libc malloc exists. */
+- GL(dl_initial_dtv) = GET_DTV (tcbp);
+-
+- __libc_malloc_pthread_startup (false);
+- }
+-# endif
+-
+ self = THREAD_SELF;
+
+ /* The memory for the thread descriptor was allocated elsewhere as
+@@ -464,17 +417,9 @@
+ }
+
+ #ifdef SHARED
+-# if USE___THREAD
+ /* When using __thread for this, we do it in libc so as not
+ to give libpthread its own TLS segment just for this. */
+ extern void **__libc_dl_error_tsd (void) __attribute__ ((const));
+-# else
+-static void ** __attribute__ ((const))
+-__libc_dl_error_tsd (void)
+-{
+- return &thread_self ()->p_libc_specific[_LIBC_TSD_KEY_DL_ERROR];
+-}
+-# endif
+ #endif
+
+ #ifdef USE_TLS
+--- a/linuxthreads/sysdeps/i386/tls.h
++++ b/linuxthreads/sysdeps/i386/tls.h
+@@ -70,8 +70,7 @@
+ But some of the code below can cause problems in building libpthread
+ (e.g. useldt.h will defined FLOATING_STACKS when it shouldn't). */
+
+-#if defined HAVE_TLS_SUPPORT \
+- && (defined FLOATING_STACKS || !defined IS_IN_libpthread)
++#if (defined FLOATING_STACKS || !defined IS_IN_libpthread)
+
+ /* Signal that TLS support is available. */
+ # define USE_TLS 1
+@@ -265,7 +264,7 @@
+ #define THREAD_GSCOPE_WAIT() \
+ do { /* GL(dl_wait_lookup_done) () */ } while (0)
+
+-# endif /* HAVE_TLS_SUPPORT && (FLOATING_STACKS || !IS_IN_libpthread) */
++# endif /* FLOATING_STACKS || !IS_IN_libpthread */
+ #endif /* __ASSEMBLER__ */
+
+ #endif /* tls.h */
+--- a/linuxthreads/sysdeps/mips/tls.h
++++ b/linuxthreads/sysdeps/mips/tls.h
+@@ -69,8 +69,7 @@
+ To avoid bothering with the TLS support code at all, use configure
+ --without-tls. */
+
+-#if defined HAVE_TLS_SUPPORT \
+- && (defined FLOATING_STACKS || !defined IS_IN_libpthread)
++#if defined FLOATING_STACKS || !defined IS_IN_libpthread
+
+ /* Signal that TLS support is available. */
+ # define USE_TLS 1
+@@ -168,6 +167,6 @@
+
+ # endif /* __ASSEMBLER__ */
+
+-#endif /* HAVE_TLS_SUPPORT */
++#endif /* FLOATING_STACKS || !IS_IN_libpthread */
+
+ #endif /* tls.h */
+--- a/linuxthreads/sysdeps/pthread/errno-loc.c
++++ b/linuxthreads/sysdeps/pthread/errno-loc.c
+@@ -23,24 +23,9 @@
+ #include <linuxthreads/internals.h>
+ #include <sysdep-cancel.h>
+
+-#if ! USE___THREAD && !RTLD_PRIVATE_ERRNO
+-#undef errno
+-extern int errno;
+-#endif
+-
+ int *
+-#if ! USE___THREAD
+-weak_const_function
+-#endif
+ __errno_location (void)
+ {
+-#if ! USE___THREAD && !defined NOT_IN_libc
+- if (! SINGLE_THREAD_P)
+- {
+- pthread_descr self = thread_self();
+- return LIBC_THREAD_GETMEM (self, p_errnop);
+- }
+-#endif
+ return &errno;
+ }
+ libc_hidden_def (__errno_location)
+--- a/linuxthreads/sysdeps/pthread/herrno-loc.c
++++ b/linuxthreads/sysdeps/pthread/herrno-loc.c
+@@ -21,23 +21,11 @@
+ #include <linuxthreads/internals.h>
+ #include <sysdep-cancel.h>
+
+-#if ! USE___THREAD
+-# undef h_errno
+-extern int h_errno;
+-#endif
+-
+ /* When threaded, h_errno may be a per-thread variable. */
+ int *
+ weak_const_function
+ __h_errno_location (void)
+ {
+-#if ! USE___THREAD
+- if (! SINGLE_THREAD_P)
+- {
+- pthread_descr self = thread_self();
+- return LIBC_THREAD_GETMEM (self, p_h_errnop);
+- }
+-#endif
+ return &h_errno;
+ }
+ libc_hidden_def (__h_errno_location)
+--- a/linuxthreads/sysdeps/pthread/res-state.c
++++ b/linuxthreads/sysdeps/pthread/res-state.c
+@@ -21,27 +21,10 @@
+ #include <linuxthreads/internals.h>
+ #include <sysdep-cancel.h>
+
+-#if ! USE___THREAD
+-# undef _res
+-extern struct __res_state _res;
+-#endif
+-
+ /* When threaded, _res may be a per-thread variable. */
+ struct __res_state *
+-#if ! USE___THREAD
+-weak_const_function
+-#endif
+ __res_state (void)
+ {
+-#if ! USE___THREAD
+- if (! SINGLE_THREAD_P)
+- {
+- pthread_descr self = thread_self();
+- return LIBC_THREAD_GETMEM (self, p_resp);
+- }
+- return &_res;
+-#else
+ return __resp;
+-#endif
+ }
+ libc_hidden_def (__res_state)
+--- a/linuxthreads/sysdeps/x86_64/tls.h
++++ b/linuxthreads/sysdeps/x86_64/tls.h
+@@ -61,7 +61,7 @@
+ #endif
+
+
+-#ifdef HAVE_TLS_SUPPORT
++#if 1
+
+ /* Signal that TLS support is available. */
+ # define USE_TLS 1
+--- a/linuxthreads/sysdeps/pthread/bits/libc-tsd.h
++++ b/linuxthreads/sysdeps/pthread/bits/libc-tsd.h
+@@ -23,7 +23,7 @@
+ #include <linuxthreads/descr.h>
+ #include <tls.h>
+
+-#if USE_TLS && HAVE___THREAD
++#if 1
+
+ /* When __thread works, the generic definition is what we want. */
+ # include_next <bits/libc-tsd.h>
+--- a/linuxthreads/internals.h
++++ b/linuxthreads/internals.h
+@@ -15,6 +15,9 @@
+ #ifndef _INTERNALS_H
+ #define _INTERNALS_H 1
+
++#define USE___THREAD 1
++#define USE_TLS 1
++
+ /* Internal data structures */
+
+ /* Includes */
More information about the Glibc-bsd-commits
mailing list