aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-12-28 09:27:26 +0000
committerUlrich Drepper <drepper@redhat.com>2002-12-28 09:27:26 +0000
commit131fd126cddad8379741597892cdfcd5cab3a49f (patch)
treeae4e3dc6182f230ae952cd95fecb2ee20948387b
parentca78735936e87a2b72c553636e815bd555c4ef7e (diff)
downloadglibc-131fd126cddad8379741597892cdfcd5cab3a49f.tar.xz
glibc-131fd126cddad8379741597892cdfcd5cab3a49f.zip
Update.
2002-12-28 Ulrich Drepper <drepper@redhat.com> * descr.h (struct pthread): Move header.data.list to the back of the struct. * sysdeps/i386/tls.h (tcbhead_t): Move list to the back of the struct. (MULTIPLE_THREADS_OFFSET): Adjust offset. (SYSINFO_OFFSEET): Likewise. 2002-12-27 Jakub Jelinek <jakub@redhat.com> * sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h (USE_DL_SYSINFO): Define. (DL_SYSINFO_DEFAULT): Cast to uintptr_t to avoid warnings. * sysdeps/unix/sysv/linux/i386/dl-sysdep.h (NEED_DL_SYSINFO, DL_SYSINFO_DEFAULT, DL_SYSINFO_IMPLEMENTATION): Define. (USE_DL_SYSINFO): Undef. 2002-12-22 Jakub Jelinek <jakub@redhat.com> * Makefile (tests-reverse): Use $(objpfx)../libc.so instead of $(common-objpfx)libc.so. * tst-cancel4.c (tf_write, tf_writev): Increase buf sizes so that it is bigger than pipe buffer size even on arches with bigger page size. (tf_usleep): Cast usleep argument to useconds_t to avoid warnings.
-rw-r--r--elf/rtld.c14
-rw-r--r--linuxthreads/Makefile12
-rw-r--r--linuxthreads/descr.h4
-rw-r--r--linuxthreads/libc_pthread_init.c3
-rw-r--r--linuxthreads/sysdeps/i386/tls.h21
-rw-r--r--linuxthreads/sysdeps/ia64/tls.h64
-rw-r--r--linuxthreads/sysdeps/pthread/bits/libc-lock.h4
-rw-r--r--linuxthreads/sysdeps/sparc/sparc32/tls.h61
-rw-r--r--linuxthreads/sysdeps/sparc/sparc64/tls.h61
-rw-r--r--linuxthreads/sysdeps/unix/sysv/linux/i386/dl-sysdep.h60
-rw-r--r--linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h2
-rw-r--r--linuxthreads/sysdeps/unix/sysv/linux/ia64/Makefile3
-rw-r--r--linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h118
-rw-r--r--linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h99
-rw-r--r--linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h98
-rw-r--r--linuxthreads/sysdeps/x86_64/tls.h5
-rw-r--r--nptl/ChangeLog26
-rw-r--r--nptl/Makefile4
-rw-r--r--nptl/descr.h2
-rw-r--r--nptl/sysdeps/i386/tls.h6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/dl-sysdep.h26
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h5
-rw-r--r--nptl/tst-cancel4.c6
-rw-r--r--sysdeps/generic/libc-start.c4
-rw-r--r--sysdeps/generic/libc-tls.c21
-rw-r--r--sysdeps/unix/common/pause.c12
-rw-r--r--sysdeps/unix/sysv/linux/i386/sysdep.h5
-rw-r--r--sysdeps/unix/sysv/linux/ia64/sysdep.h101
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S10
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/socket.S7
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S28
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h52
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S7
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/socket.S6
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S10
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h50
36 files changed, 907 insertions, 110 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index d510018cb4..b8e7f9af6b 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -1150,6 +1150,10 @@ of this helper program; chances are you did not intend to run this program.\n\
/* Assign a module ID. */
GL(dl_rtld_map).l_tls_modid = _dl_next_tls_modid ();
+# ifndef TLS_INIT_TP_EXPENSIVE
+# define TLS_INIT_TP_EXPENSIVE 0
+# endif
+
/* We do not initialize any of the TLS functionality unless any of the
initial modules uses TLS. This makes dynamic loading of modules with
TLS impossible, but to support it requires either eagerly doing setup
@@ -1157,7 +1161,7 @@ of this helper program; chances are you did not intend to run this program.\n\
an old kernel that can't perform TLS_INIT_TP, even if no TLS is ever
used. Trying to do it lazily is too hairy to try when there could be
multiple threads (from a non-TLS-using libpthread). */
- if (GL(dl_tls_max_dtv_idx) > 0)
+ if (GL(dl_tls_max_dtv_idx) > 0 || !TLS_INIT_TP_EXPENSIVE)
{
struct link_map *l;
size_t nelem;
@@ -1565,8 +1569,12 @@ cannot allocate TLS data structures for initial thread");
we need it in the memory handling later. */
GL(dl_initial_searchlist) = *GL(dl_main_searchlist);
+#ifndef NONTLS_INIT_TP
+# define NONTLS_INIT_TP do { } while (0)
+#endif
+
#ifdef USE_TLS
- if (GL(dl_tls_max_dtv_idx) > 0 || USE___THREAD)
+ if (GL(dl_tls_max_dtv_idx) > 0 || USE___THREAD || !TLS_INIT_TP_EXPENSIVE)
{
/* Now that we have completed relocation, the initializer data
for the TLS blocks has its final values and we can copy them
@@ -1579,7 +1587,9 @@ cannot allocate TLS data structures for initial thread");
if (__builtin_expect (lossage != NULL, 0))
_dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage);
}
+ else
#endif
+ NONTLS_INIT_TP;
{
/* Initialize _r_debug. */
diff --git a/linuxthreads/Makefile b/linuxthreads/Makefile
index e9cbf5e8b8..6425108389 100644
--- a/linuxthreads/Makefile
+++ b/linuxthreads/Makefile
@@ -74,8 +74,12 @@ endif
librt-tests = ex10 ex11
tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 $(librt-tests) ex12 ex13 joinrace \
tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 \
- ex17 ex18 tst-cancel tst-context bug-sleep
+ ex17 ex18 tst-cancel tst-context bug-sleep \
+ tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \
+ tst-cancel6
test-srcs = tst-signal
+# These tests are linked with libc before libpthread
+tests-reverse += tst-cancel5
ifeq ($(build-static),yes)
tests += tststatic tst-static-locale
@@ -149,8 +153,12 @@ $(objpfx)libpthread.so: $(libc-link.so) $(common-objpfx)libc_nonshared.a
# Make sure we link with the thread library.
ifeq ($(build-shared),yes)
$(addprefix $(objpfx), \
- $(filter-out $(tests-static) unload, \
+ $(filter-out $(tests-static) $(tests-reverse) unload, \
$(tests) $(test-srcs))): $(objpfx)libpthread.so
+# $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
+# since otherwise libpthread.so comes before libc.so when linking.
+$(addprefix $(objpfx), $(tests-reverse)): \
+ $(objpfx)../libc.so $(objpfx)libpthread.so
$(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.so
$(objpfx)unload: $(common-objpfx)dlfcn/libdl.so
$(objpfx)unload.out: $(objpfx)libpthread.so
diff --git a/linuxthreads/descr.h b/linuxthreads/descr.h
index 94ad893979..74ef25e1f4 100644
--- a/linuxthreads/descr.h
+++ b/linuxthreads/descr.h
@@ -20,6 +20,7 @@
#include <sched.h>
#include <setjmp.h>
#include <signal.h>
+#include <stdint.h>
#include <sys/types.h>
#include <hp-timing.h>
#include <bits/libc-tsd.h> /* for _LIBC_TSD_KEY_N */
@@ -107,6 +108,9 @@ struct _pthread_descr_struct {
union dtv *dtvp;
pthread_descr self; /* Pointer to this structure */
int multiple_threads;
+#ifdef NEED_DL_SYSINFO
+ uintptr_t sysinfo;
+#endif
} data;
void *__padding[16];
} p_header;
diff --git a/linuxthreads/libc_pthread_init.c b/linuxthreads/libc_pthread_init.c
index 901d333fbf..c952b22d07 100644
--- a/linuxthreads/libc_pthread_init.c
+++ b/linuxthreads/libc_pthread_init.c
@@ -17,9 +17,10 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <locale.h>
+#include <stdlib.h>
#include <string.h>
#include <tls.h>
-#include <locale.h>
#include "internals.h"
#include <sysdep-cancel.h>
diff --git a/linuxthreads/sysdeps/i386/tls.h b/linuxthreads/sysdeps/i386/tls.h
index c244801bf4..761a8ca943 100644
--- a/linuxthreads/sysdeps/i386/tls.h
+++ b/linuxthreads/sysdeps/i386/tls.h
@@ -20,10 +20,12 @@
#ifndef _TLS_H
#define _TLS_H
+# include <dl-sysdep.h>
# include <pt-machine.h>
#ifndef __ASSEMBLER__
# include <stddef.h>
+# include <stdint.h>
/* Type for the dtv. */
typedef union dtv
@@ -39,9 +41,17 @@ typedef struct
thread descriptor used by libpthread. */
dtv_t *dtv;
void *self; /* Pointer to the thread descriptor. */
+ int multiple_threads;
+#ifdef NEED_DL_SYSINFO
+ uintptr_t sysinfo;
+#endif
} tcbhead_t;
#endif
+#ifdef NEED_DL_SYSINFO
+/* Offset of the SYSINFO element in tcbhead_t. */
+# define SYSINFO_OFFSET 24
+#endif
/* We can support TLS only if the floating-stack support is available.
However, we want to compile in the support and test at runtime whether
@@ -174,6 +184,12 @@ TLS_DO_MODIFY_LDT_KERNEL_CHECK( \
TLS_DO_MODIFY_LDT ((descr), 0)
# endif
+#if defined NEED_DL_SYSINFO && defined SHARED
+# define INIT_SYSINFO \
+ head->sysinfo = GL(dl_sysinfo)
+#else
+# define INIT_SYSINFO
+#endif
/* Code to initially initialize the thread pointer. This might need
special attention since 'errno' is not yet available and if the
@@ -189,9 +205,14 @@ TLS_DO_MODIFY_LDT_KERNEL_CHECK( \
/* For now the thread descriptor is at the same address. */ \
head->self = _descr; \
\
+ INIT_SYSINFO; \
TLS_SETUP_GS_SEGMENT (_descr, secondcall); \
})
+/* Indicate that dynamic linker shouldn't try to initialize TLS even
+ when no PT_TLS segments are found in the program and libraries
+ it is linked against. */
+# define TLS_INIT_TP_EXPENSIVE 1
/* Return the address of the dtv for the current thread. */
# define THREAD_DTV() \
diff --git a/linuxthreads/sysdeps/ia64/tls.h b/linuxthreads/sysdeps/ia64/tls.h
new file mode 100644
index 0000000000..c270795254
--- /dev/null
+++ b/linuxthreads/sysdeps/ia64/tls.h
@@ -0,0 +1,64 @@
+/* Definitions for thread-local data handling. linuxthreads/IA-64 version.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#ifndef __ASSEMBLER__
+
+# include <pt-machine.h>
+# include <stddef.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ void *pointer;
+} dtv_t;
+
+
+/* FIXME: Only temporary. When TLS is supported on IA-64,
+ pthread_descr struct needs to be immediately below r13 and
+ at r13 a struct { dtv_t *dtv; void *private; }. */
+typedef struct
+{
+ void *tcb; /* Pointer to the TCB. Not necessary the
+ thread descriptor used by libpthread. */
+ dtv_t *dtv;
+ void *self; /* Pointer to the thread descriptor. */
+ int multiple_threads;
+} tcbhead_t;
+#endif /* __ASSEMBLER__ */
+
+#undef USE_TLS
+
+#if USE_TLS
+
+#else
+
+#define NONTLS_INIT_TP \
+ do { \
+ static const tcbhead_t nontls_init_tp \
+ = { .multiple_threads = 0 }; \
+ __thread_self = (__typeof (__thread_self)) &nontls_init_tp; \
+ } while (0)
+
+#endif /* USE_TLS */
+
+#endif /* tls.h */
diff --git a/linuxthreads/sysdeps/pthread/bits/libc-lock.h b/linuxthreads/sysdeps/pthread/bits/libc-lock.h
index 217b0be253..cb839fa42e 100644
--- a/linuxthreads/sysdeps/pthread/bits/libc-lock.h
+++ b/linuxthreads/sysdeps/pthread/bits/libc-lock.h
@@ -97,7 +97,7 @@ typedef pthread_key_t __libc_key_t;
#if defined _LIBC && defined IS_IN_libpthread
# define __libc_maybe_call(FUNC, ARGS, ELSE) FUNC ARGS
#else
-# ifdef __PIC__
+# if defined __PIC__ || (defined _LIBC && defined SHARED)
# define __libc_maybe_call(FUNC, ARGS, ELSE) \
(__extension__ ({ __typeof (FUNC) *_fn = (FUNC); \
_fn != NULL ? (*_fn) ARGS : ELSE; }))
@@ -106,7 +106,7 @@ typedef pthread_key_t __libc_key_t;
(FUNC != NULL ? FUNC ARGS : ELSE)
# endif
#endif
-#if defined _LIBC && !defined NOT_IN_libc && defined __PIC__
+#if defined _LIBC && !defined NOT_IN_libc && defined SHARED
# define __libc_maybe_call2(FUNC, ARGS, ELSE) \
({__libc_pthread_functions.ptr_##FUNC != NULL \
? __libc_pthread_functions.ptr_##FUNC ARGS : ELSE; })
diff --git a/linuxthreads/sysdeps/sparc/sparc32/tls.h b/linuxthreads/sysdeps/sparc/sparc32/tls.h
new file mode 100644
index 0000000000..1b316d0b33
--- /dev/null
+++ b/linuxthreads/sysdeps/sparc/sparc32/tls.h
@@ -0,0 +1,61 @@
+/* Definitions for thread-local data handling. linuxthreads/sparc32 version.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#ifndef __ASSEMBLER__
+
+# include <pt-machine.h>
+# include <stddef.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ void *pointer;
+} dtv_t;
+
+typedef struct
+{
+ void *tcb; /* Pointer to the TCB. Not necessary the
+ thread descriptor used by libpthread. */
+ dtv_t *dtv;
+ void *self; /* Pointer to the thread descriptor. */
+ int multiple_threads;
+} tcbhead_t;
+
+#endif /* __ASSEMBLER__ */
+
+#undef USE_TLS
+
+#if USE_TLS
+
+#else
+
+#define NONTLS_INIT_TP \
+ do { \
+ static const tcbhead_t nontls_init_tp \
+ = { .multiple_threads = 0 }; \
+ __thread_self = (__typeof (__thread_self)) &nontls_init_tp; \
+ } while (0)
+
+#endif /* USE_TLS */
+
+#endif /* tls.h */
diff --git a/linuxthreads/sysdeps/sparc/sparc64/tls.h b/linuxthreads/sysdeps/sparc/sparc64/tls.h
new file mode 100644
index 0000000000..039ad2bc48
--- /dev/null
+++ b/linuxthreads/sysdeps/sparc/sparc64/tls.h
@@ -0,0 +1,61 @@
+/* Definitions for thread-local data handling. linuxthreads/sparc64 version.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TLS_H
+#define _TLS_H
+