about summary refs log tree commit diff
path: root/linuxthreads
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads')
-rw-r--r--linuxthreads/ChangeLog34
-rw-r--r--linuxthreads/Makefile7
-rw-r--r--linuxthreads/cancel.c1
-rw-r--r--linuxthreads/lockfile.c6
-rw-r--r--linuxthreads/semaphore.h1
-rw-r--r--linuxthreads/sysdeps/alpha/tls.h46
-rw-r--r--linuxthreads/sysdeps/i386/tls.h9
-rw-r--r--linuxthreads/sysdeps/ia64/tls.h9
-rw-r--r--linuxthreads/sysdeps/powerpc/tls.h12
-rw-r--r--linuxthreads/sysdeps/pthread/Makefile12
-rw-r--r--linuxthreads/sysdeps/pthread/nptl-struct-pthread.sym13
-rw-r--r--linuxthreads/sysdeps/s390/tls.h9
-rw-r--r--linuxthreads/sysdeps/sh/tls.h9
-rw-r--r--linuxthreads/sysdeps/sparc/tls.h9
-rw-r--r--linuxthreads/sysdeps/x86_64/tls.h9
-rw-r--r--linuxthreads/tst-tls1.h2
16 files changed, 164 insertions, 24 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index f2a275f405..63d3faf364 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -623,6 +623,12 @@
 	(pthread_barrierattr_setpshared): Return EINVAL if pshared
 	is neither PTHREAD_PROCESS_PRIVATE nor PTHREAD_PROCESS_SHARED.
 
+2003-09-02  Jakub Jelinek  <jakub@redhat.com>
+
+	* sysdeps/sparc/tls.h (TLS_TCB_SIZE): If in ld.so and NPTL struct
+	pthread is bigger than struct _pthread_descr_struct, use NPTL struct
+	pthread size.
+
 2003-09-02  Ulrich Drepper  <drepper@redhat.com>
 
 	* sysdeps/unix/sysv/linux/i386/dl-sysdep.h
@@ -755,6 +761,34 @@
 
 2003-07-22  Jakub Jelinek  <jakub@redhat.com>
 
+	* sysdeps/alpha/tls.h (TLS_INIT_TCB_SIZE, TLS_TCB_SIZE): Change to 0.
+	(TLS_INIT_TCB_ALIGN, TLS_TCB_ALIGN): Alignment of struct
+	_pthread_descr_struct.
+	(TLS_PRE_TCB_SIZE): Add sizeof (tcbhead_t) and pad to align.
+	If in ld.so and NPTL struct pthread is bigger than struct
+	_pthread_descr_struct, use NPTL struct pthread size.
+	(TLS_TCB_OFFSET): Define.
+	(INSTALL_DTV, INSTALL_NEW_DTV, GET_DTV, TLS_INIT_TP, THREAD_DTV,
+	THREAD_SELF, INIT_THREAD_SELF): Changed to match NPTL tls.h
+	definitions.
+	* sysdeps/i386/tls.h (TLS_TCB_SIZE): If in ld.so and NPTL struct
+	pthread is bigger than struct _pthread_descr_struct, use NPTL struct
+	pthread size.
+	* sysdeps/ia64/tls.h (TLS_PRE_TCB_SIZE): Likewise.
+	* sysdeps/powerpc/tls.h (TLS_PRE_TCB_SIZE): Likewise.
+	* sysdeps/s390/tls.h (TLS_TCB_SIZE): Likewise.
+	* sysdeps/sh/tls.h (TLS_PRE_TCB_SIZE): Likewise.
+	* sysdeps/x86_64/tls.h (TLS_TCB_SIZE): Likewise.
+	* sysdeps/pthread/Makefile (gen-as-const-headers): Add
+	nptl-struct-pthread.sym if nptl tree is present.
+	(before-compile): Add $(common-objpfx)nptl-struct-pthread.h
+	if nptl tree is not present.
+	(common-generated): Add nptl-struct-pthread.h.
+	($(common-objpfx)nptl-struct-pthread.h): New rule.
+	* sysdeps/pthread/nptl-struct-pthread.sym: New file.
+
+2003-07-22  Jakub Jelinek  <jakub@redhat.com>
+
 	* descr.h (struct _pthread_descr_struct): Provide p_res member
 	even if USE_TLS && HAVE___THREAD.
 	* sysdeps/pthread/res-state.c (__res_state): Return __resp
diff --git a/linuxthreads/Makefile b/linuxthreads/Makefile
index a16ae8d2da..5bf558334d 100644
--- a/linuxthreads/Makefile
+++ b/linuxthreads/Makefile
@@ -254,15 +254,18 @@ $(addprefix $(objpfx), \
   $(filter-out $(tests-static) $(tests-reverse) unload, \
     $(tests) $(test-srcs))): $(objpfx)libpthread.so \
 			     $(objpfx)libpthread_nonshared.a
-# $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
+# $(objpfx)linklibc.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 \
+  $(objpfx)linklibc.so $(objpfx)libpthread.so \
   $(objpfx)libpthread_nonshared.a
 $(objpfx)../libc.so: $(common-objpfx)libc.so ;
 $(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.so
 $(objpfx)unload: $(common-objpfx)dlfcn/libdl.so
 $(objpfx)unload.out: $(objpfx)libpthread.so $(objpfx)libpthread_nonshared.a
+$(objpfx)linklibc.so: $(common-objpfx)libc.so
+	ln -s ../libc.so $@
+generated += libclink.so
 else
 $(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a
 $(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.a
diff --git a/linuxthreads/cancel.c b/linuxthreads/cancel.c
index d8053ca899..2844210a87 100644
--- a/linuxthreads/cancel.c
+++ b/linuxthreads/cancel.c
@@ -230,5 +230,6 @@ void __pthread_perform_cleanup(char *currentframe)
     }
 
   /* And the TSD which needs special help.  */
+  THREAD_SETMEM (self, p_cancelstate, PTHREAD_CANCEL_DISABLE);
   __libc_thread_freeres ();
 }
diff --git a/linuxthreads/lockfile.c b/linuxthreads/lockfile.c
index 34055e4115..6d683b4235 100644
--- a/linuxthreads/lockfile.c
+++ b/linuxthreads/lockfile.c
@@ -74,7 +74,11 @@ __fresetlockfiles (void)
   __pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE_NP);
 
   for (i = _IO_iter_begin(); i != _IO_iter_end(); i = _IO_iter_next(i))
-    __pthread_mutex_init (_IO_iter_file(i)->_lock, &attr);
+    {
+      _IO_lock_t *_lock = _IO_iter_file(i)->_lock;
+      if (_lock)
+	__pthread_mutex_init (_lock, &attr);
+    }
 
   __pthread_mutexattr_destroy (&attr);
 
diff --git a/linuxthreads/semaphore.h b/linuxthreads/semaphore.h
index 8407007d0b..3c9696d12a 100644
--- a/linuxthreads/semaphore.h
+++ b/linuxthreads/semaphore.h
@@ -21,6 +21,7 @@
 # define __need_timespec
 # include <time.h>
 #endif
+#include <bits/pthreadtypes.h>
 
 #ifndef _PTHREAD_DESCR_DEFINED
 /* Thread descriptors.  Needed for `sem_t' definition.  */
diff --git a/linuxthreads/sysdeps/alpha/tls.h b/linuxthreads/sysdeps/alpha/tls.h
index 261d333eb4..9e15318b79 100644
--- a/linuxthreads/sysdeps/alpha/tls.h
+++ b/linuxthreads/sysdeps/alpha/tls.h
@@ -53,54 +53,76 @@ typedef struct
 #  include <sysdep.h>
 
 /* This is the size of the initial TCB.  */
-#  define TLS_INIT_TCB_SIZE	sizeof (tcbhead_t)
+#  define TLS_INIT_TCB_SIZE	0
 
 /* Alignment requirements for the initial TCB.  */
-#  define TLS_INIT_TCB_ALIGN	__alignof__ (tcbhead_t)
+#  define TLS_INIT_TCB_ALIGN	__alignof__ (struct _pthread_descr_struct)
 
 /* This is the size of the TCB.  */
-#  define TLS_TCB_SIZE		sizeof (tcbhead_t)
+#  define TLS_TCB_SIZE		0
 
 /* Alignment requirements for the TCB.  */
-#  define TLS_TCB_ALIGN		__alignof__ (tcbhead_t)
+#  define TLS_TCB_ALIGN		__alignof__ (struct _pthread_descr_struct)
 
 /* This is the size we need before TCB.  */
-#  define TLS_PRE_TCB_SIZE	sizeof (struct _pthread_descr_struct)
+#  ifndef IS_IN_rtld
+#   define TLS_PRE_TCB_SIZE \
+  (sizeof (struct _pthread_descr_struct)				\
+   + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
+#  else
+#   include <nptl-struct-pthread.h>
+#   define TLS_PRE_TCB_SIZE \
+  ((sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE	\
+    ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE)	\
+   + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
+#  endif
 
 /* The DTV is allocated at the TP; the TCB is placed elsewhere.  */
 #  define TLS_DTV_AT_TP 1
 
+/* The following assumes that TP (R2 or R13) points to the end of the
+   TCB + 0x7000 (per the ABI).  This implies that TCB address is
+   TP - 0x7000.  As we define TLS_DTV_AT_TP we can
+   assume that the pthread struct is allocated immediately ahead of the
+   TCB.  This implies that the pthread_descr address is
+   TP - (TLS_PRE_TCB_SIZE + 0x7000).  */
+/* ??? PPC uses offset 0x7000; seems like a good idea for alpha too,
+   but binutils not yet changed to match.  */
+#  define TLS_TCB_OFFSET 0
+
 /* Install the dtv pointer.  The pointer passed is to the element with
    index -1 which contain the length.  */
 #  define INSTALL_DTV(TCBP, DTVP) \
-  (((tcbhead_t *) (TCBP))->dtv = (DTVP) + 1)
+  (((tcbhead_t *) (TCBP))[-1].dtv = (DTVP) + 1)
 
 /* Install new dtv for current thread.  */
 #  define INSTALL_NEW_DTV(DTV) \
-  (((tcbhead_t *)__builtin_thread_pointer ())->dtv = (DTV))
+  (THREAD_DTV() = (DTV))
 
 /* Return dtv of given thread descriptor.  */
 #  define GET_DTV(TCBP) \
-  (((tcbhead_t *) (TCBP))->dtv)
+  (((tcbhead_t *) (TCBP))[-1].dtv)
 
 /* Code to initially initialize the thread pointer.  This might need
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
 # define TLS_INIT_TP(TCBP, SECONDCALL) \
-  (__builtin_set_thread_pointer (TCBP), 0)
+  (__builtin_set_thread_pointer ((void *) (TCBP) + TLS_TCB_OFFSET), NULL)
 
 /* Return the address of the dtv for the current thread.  */
 #  define THREAD_DTV() \
-  (((tcbhead_t *)__builtin_thread_pointer ())->dtv)
+  (((tcbhead_t *) (__builtin_thread_pointer () - TLS_TCB_OFFSET))[-1].dtv)
 
 /* Return the thread descriptor for the current thread.  */
 #  undef THREAD_SELF
 #  define THREAD_SELF \
-  ((pthread_descr)__builtin_thread_pointer () - 1)
+  ((pthread_descr) (__builtin_thread_pointer () \
+		    - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
 
 #  undef INIT_THREAD_SELF
 #  define INIT_THREAD_SELF(DESCR, NR) \
-  __builtin_set_thread_pointer ((struct _pthread_descr_struct *)(DESCR) + 1)
+  __builtin_set_thread_pointer ((char *)(DESCR) \
+				+ TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE)
 
 /* Get the thread descriptor definition.  */
 #  include <linuxthreads/descr.h>
diff --git a/linuxthreads/sysdeps/i386/tls.h b/linuxthreads/sysdeps/i386/tls.h
index 569a897474..84d87db359 100644
--- a/linuxthreads/sysdeps/i386/tls.h
+++ b/linuxthreads/sysdeps/i386/tls.h
@@ -81,7 +81,14 @@ typedef struct
 #  define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
 
 /* This is the size of the TCB.  */
-#  define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct)
+#  ifndef IS_IN_rtld
+#   define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct)
+#  else
+#   include <nptl-struct-pthread.h>
+#   define TLS_TCB_SIZE \
+  (sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE	\
+   ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE)
+#  endif
 
 /* Alignment requirements for the TCB.  */
 #  define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
diff --git a/linuxthreads/sysdeps/ia64/tls.h b/linuxthreads/sysdeps/ia64/tls.h
index 3ec2eda783..6bdf819d8d 100644
--- a/linuxthreads/sysdeps/ia64/tls.h
+++ b/linuxthreads/sysdeps/ia64/tls.h
@@ -60,7 +60,14 @@ typedef struct
 #  define TLS_TCB_SIZE sizeof (tcbhead_t)
 
 /* This is the size we need before TCB.  */
-#  define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
+#  ifndef IS_IN_rtld
+#   define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
+#  else
+#   include <nptl-struct-pthread.h>
+#   define TLS_PRE_TCB_SIZE \
+  (sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE	\
+   ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE)
+#  endif
 
 /* Alignment requirements for the TCB.  */
 #  define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
diff --git a/linuxthreads/sysdeps/powerpc/tls.h b/linuxthreads/sysdeps/powerpc/tls.h
index f6eb48b434..fda953976e 100644
--- a/linuxthreads/sysdeps/powerpc/tls.h
+++ b/linuxthreads/sysdeps/powerpc/tls.h
@@ -64,11 +64,19 @@ typedef struct
 #  define TLS_TCB_ALIGN		__alignof__ (struct _pthread_descr_struct)
 
 /* This is the size we need before TCB.  */
-#  define TLS_PRE_TCB_SIZE \
+#  ifndef IS_IN_rtld
+#   define TLS_PRE_TCB_SIZE \
   (sizeof (struct _pthread_descr_struct)				      \
    + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
+#  else
+#   include <nptl-struct-pthread.h>
+#   define TLS_PRE_TCB_SIZE \
+  ((sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE	      \
+    ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE)	      \
+   + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
+#  endif
 
-/* The following assumes that TP (R2 or R13) is points to the end of the
+/* The following assumes that TP (R2 or R13) points to the end of the
    TCB + 0x7000 (per the ABI).  This implies that TCB address is
    TP - 0x7000.  As we define TLS_DTV_AT_TP we can
    assume that the pthread_descr is allocated immediately ahead of the
diff --git a/linuxthreads/sysdeps/pthread/Makefile b/linuxthreads/sysdeps/pthread/Makefile
index f73f40e9d9..6f5a296e3c 100644
--- a/linuxthreads/sysdeps/pthread/Makefile
+++ b/linuxthreads/sysdeps/pthread/Makefile
@@ -12,3 +12,15 @@ endif
 ifeq ($(subdir),posix)
 CFLAGS-confstr.c += -DLIBPTHREAD_VERSION="\"$(shell sed 's/\(.*\) by .*/\1/' ../linuxthreads/Banner)\""
 endif
+
+ifeq ($(subdir),csu)
+# Find out the size of NPTL struct pthread
+ifneq (,$(wildcard $(..)nptl/descr.h))
+gen-as-const-headers += nptl-struct-pthread.sym
+else
+before-compile += $(common-objpfx)nptl-struct-pthread.h
+common-generated += nptl-struct-pthread.h
+$(common-objpfx)nptl-struct-pthread.h:
+	@echo '#define NPTL_STRUCT_PTHREAD_SIZE 0' > $@
+endif
+endif
diff --git a/linuxthreads/sysdeps/pthread/nptl-struct-pthread.sym b/linuxthreads/sysdeps/pthread/nptl-struct-pthread.sym
new file mode 100644
index 0000000000..8df995270e
--- /dev/null
+++ b/linuxthreads/sysdeps/pthread/nptl-struct-pthread.sym
@@ -0,0 +1,13 @@
+#ifdef HAVE_TLS_SUPPORT
+# ifndef HAVE_FORCED_UNWIND
+#  define HAVE_FORCED_UNWIND 1
+# endif
+# define __need_struct_pthread_size
+# include <nptl/descr.h>
+#endif
+
+--
+
+#ifdef HAVE_TLS_SUPPORT
+NPTL_STRUCT_PTHREAD_SIZE	sizeof (struct pthread)
+#endif
diff --git a/linuxthreads/sysdeps/s390/tls.h b/linuxthreads/sysdeps/s390/tls.h
index 41a83a72fb..f420195bd2 100644
--- a/linuxthreads/sysdeps/s390/tls.h
+++ b/linuxthreads/sysdeps/s390/tls.h
@@ -72,7 +72,14 @@ typedef struct
 #  define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
 
 /* This is the size of the TCB.  */
-#  define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct)
+#  ifndef IS_IN_rtld
+#   define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct)
+#  else
+#   include <nptl-struct-pthread.h>
+#   define TLS_TCB_SIZE \
+  (sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE	\
+   ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE)
+#  endif
 
 /* Alignment requirements for the TCB.  */
 #  define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
diff --git a/linuxthreads/sysdeps/sh/tls.h b/linuxthreads/sysdeps/sh/tls.h
index 17a247c6b6..bc9d44fa85 100644
--- a/linuxthreads/sysdeps/sh/tls.h
+++ b/linuxthreads/sysdeps/sh/tls.h
@@ -64,7 +64,14 @@ typedef struct
 #  define TLS_TCB_SIZE sizeof (tcbhead_t)
 
 /* This is the size we need before TCB.  */
-#  define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
+#  ifndef IS_IN_rtld
+#   define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
+#  else
+#   include <nptl-struct-pthread.h>
+#   define TLS_PRE_TCB_SIZE \
+  (sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE	\
+   ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE)
+#  endif
 
 /* Alignment requirements for the TCB.  */
 #  define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
diff --git a/linuxthreads/sysdeps/sparc/tls.h b/linuxthreads/sysdeps/sparc/tls.h
index 6b1966fe1c..5053824058 100644
--- a/linuxthreads/sysdeps/sparc/tls.h
+++ b/linuxthreads/sysdeps/sparc/tls.h
@@ -64,7 +64,14 @@ typedef struct
 #  define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
 
 /* This is the size of the TCB.  */
-#  define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct)
+#  ifndef IS_IN_rtld
+#   define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct)
+#  else
+#   include <nptl-struct-pthread.h>
+#   define TLS_TCB_SIZE \
+  (sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE	\
+   ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE)
+#  endif
 
 /* Alignment requirements for the TCB.  */
 #  define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
diff --git a/linuxthreads/sysdeps/x86_64/tls.h b/linuxthreads/sysdeps/x86_64/tls.h
index 63feebdb2c..d979bbd896 100644
--- a/linuxthreads/sysdeps/x86_64/tls.h
+++ b/linuxthreads/sysdeps/x86_64/tls.h
@@ -66,7 +66,14 @@ typedef struct
 #  define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
 
 /* This is the size of the TCB.  */
-#  define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct)
+#  ifndef IS_IN_rtld
+#   define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct)
+#  else
+#   include <nptl-struct-pthread.h>
+#   define TLS_TCB_SIZE \
+  (sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE	\
+   ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE)
+#  endif
 
 /* Alignment requirements for the TCB.  */
 #  define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
diff --git a/linuxthreads/tst-tls1.h b/linuxthreads/tst-tls1.h
index b7c14eb82c..0060e5727b 100644
--- a/linuxthreads/tst-tls1.h
+++ b/linuxthreads/tst-tls1.h
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 #include <tls.h>
 
-#if USE_TLS && HAVE___THREAD
+#if USE_TLS && (0 || HAVE___THREAD)
 
 struct tls_obj
 {