aboutsummaryrefslogtreecommitdiff
path: root/nptl/sysdeps
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-04-25 09:12:43 +0000
committerUlrich Drepper <drepper@redhat.com>2003-04-25 09:12:43 +0000
commit299601a1ef8df4532ded24194c4556e294ab1e6e (patch)
tree7e7338ca0004ce7fdba3e7429677ef0a5786ad8f /nptl/sysdeps
parent29bfc9453e2945b476cec5545f8409fd2a2ba886 (diff)
downloadglibc-299601a1ef8df4532ded24194c4556e294ab1e6e.zip
glibc-299601a1ef8df4532ded24194c4556e294ab1e6e.tar.gz
glibc-299601a1ef8df4532ded24194c4556e294ab1e6e.tar.bz2
Update.
2003-04-22 Jakub Jelinek <jakub@redhat.com> * include/link.h (NO_TLS_OFFSET): Define to 0 if not defined. * elf/dl-close.c (_dl_close): Use NO_TLS_OFFSET. * elf/dl-object.c (_dl_new_object): Initialize l_tls_offset to NO_TLS_OFFSET. * elf/rtld.c (_dl_start_final, _dl_start): Likewise. * elf/dl-reloc.c (CHECK_STATIC_TLS): Use NO_TLS_OFFSET. * sysdeps/generic/dl-tls.c (_dl_allocate_tls_init): Likewise. * sysdeps/powerpc/dl-tls.h (TLS_TPREL_VALUE): Don't subtract TLS_TCB_SIZE.
Diffstat (limited to 'nptl/sysdeps')
-rw-r--r--nptl/sysdeps/ia64/tcb-offsets.sym2
-rw-r--r--nptl/sysdeps/powerpc/tcb-offsets.sym11
-rw-r--r--nptl/sysdeps/powerpc/tls.h31
-rw-r--r--nptl/sysdeps/pthread/createthread.c8
-rw-r--r--nptl/sysdeps/sh/tcb-offsets.sym2
-rw-r--r--nptl/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h2
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c2
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h3
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h3
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h3
10 files changed, 32 insertions, 35 deletions
diff --git a/nptl/sysdeps/ia64/tcb-offsets.sym b/nptl/sysdeps/ia64/tcb-offsets.sym
index 11cc06a..9f92bb6 100644
--- a/nptl/sysdeps/ia64/tcb-offsets.sym
+++ b/nptl/sysdeps/ia64/tcb-offsets.sym
@@ -1,4 +1,4 @@
#include <sysdep.h>
#include <tls.h>
-MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads) - sizeof (struct pthread)
+MULTIPLE_THREADS_OFFSET -sizeof(int)
diff --git a/nptl/sysdeps/powerpc/tcb-offsets.sym b/nptl/sysdeps/powerpc/tcb-offsets.sym
index d6b7560..58ee030 100644
--- a/nptl/sysdeps/powerpc/tcb-offsets.sym
+++ b/nptl/sysdeps/powerpc/tcb-offsets.sym
@@ -1,13 +1,4 @@
#include <sysdep.h>
#include <tls.h>
---
-
--- Abuse tls.h macros to derive offsets relative to the thread register.
-# undef __thread_register
-# define __thread_register ((void *) 0)
-# define thread_offsetof(mem) ((void *) &THREAD_SELF->mem - (void *) 0)
-
-#if TLS_MULTIPLE_THREADS_IN_TCB
-MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
-#endif
+MULTIPLE_THREADS_OFFSET ((void *) &p_multiple_threads ((struct pthread) ((void *) 0 - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)) - (void *) 0)
diff --git a/nptl/sysdeps/powerpc/tls.h b/nptl/sysdeps/powerpc/tls.h
index 0ef5655..e3e0424 100644
--- a/nptl/sysdeps/powerpc/tls.h
+++ b/nptl/sysdeps/powerpc/tls.h
@@ -69,22 +69,19 @@ typedef struct
} tcbhead_t;
/* 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)
/* 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)
/* This is the size we need before TCB. */
-# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
-
-/* XXX if __alignof__ (struct pthread) > __alignof (tcbhead_t)
- we could be in trouble. -- paulus */
+# define TLS_PRE_TCB_SIZE (sizeof (struct pthread) + 32)
# ifndef __powerpc64__
/* Register r2 (tp) is reserved by the ABI as "thread pointer". */
@@ -98,37 +95,37 @@ register void *__thread_register __asm__ ("r13");
/* 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-(TLS_TCB_SIZE + 0x7000). As we define TLS_DTV_AT_TP we can
+ 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 + TLS_TCB_SIZE + 0x7000). */
+ TP - (TLS_PRE_TCB_SIZE + 0x7000). */
# define TLS_TCB_OFFSET 0x7000
/* 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) (THREAD_DTV() = (dtv))
/* Return dtv of given thread descriptor. */
-# define GET_DTV(tcbp) (((tcbhead_t *) (tcbp))->dtv)
+# define GET_DTV(tcbp) (((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) \
- (__thread_register = (void *) (tcbp) + TLS_TCB_OFFSET + TLS_TCB_SIZE, NULL)
+ (__thread_register = (void *) (tcbp) + TLS_TCB_OFFSET, NULL)
/* Return the address of the dtv for the current thread. */
# define THREAD_DTV() \
- (((tcbhead_t *) (__thread_register - TLS_TCB_OFFSET - TLS_TCB_SIZE))->dtv)
+ (((tcbhead_t *) (__thread_register - TLS_TCB_OFFSET))[-1].dtv)
/* Return the thread descriptor for the current thread. */
# define THREAD_SELF \
((struct pthread *) (__thread_register \
- - TLS_TCB_OFFSET - TLS_TCB_SIZE - TLS_PRE_TCB_SIZE))
+ - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
/* Read member of the thread descriptor directly. */
# define THREAD_GETMEM(descr, member) ((void)(descr), (THREAD_SELF)->member)
@@ -145,6 +142,10 @@ register void *__thread_register __asm__ ("r13");
# define THREAD_SETMEM_NC(descr, member, idx, value) \
((void)(descr), (THREAD_SELF)->member[idx] = (value))
+/* l_tls_offset == 0 is perfectly valid on PPC, so we have to use some
+ different value to mean unset l_tls_offset. */
+# define NO_TLS_OFFSET -1
+
#endif /* __ASSEMBLER__ */
#endif /* tls.h */
diff --git a/nptl/sysdeps/pthread/createthread.c b/nptl/sysdeps/pthread/createthread.c
index 9d00e4e..f5c6406 100644
--- a/nptl/sysdeps/pthread/createthread.c
+++ b/nptl/sysdeps/pthread/createthread.c
@@ -87,7 +87,11 @@ create_thread (struct pthread *pd, STACK_VARIABLES_PARMS)
thread might not yet have the flag set. No need to set
the global variable again if this is what we use. */
#ifdef TLS_MULTIPLE_THREADS_IN_TCB
+# if TLS_DTV_AT_TP
+ p_multiple_threads (THREAD_SELF) = 1;
+# else
THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1);
+# endif
#endif
/* Now fill in the information about the new thread in
@@ -159,7 +163,11 @@ create_thread (struct pthread *pd, STACK_VARIABLES_PARMS)
not yet have the flag set. No need to set the global variable
again if this is what we use. */
#ifdef TLS_MULTIPLE_THREADS_IN_TCB
+# if TLS_DTV_AT_TP
+ p_multiple_threads (THREAD_SELF) = 1;
+# else
THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1);
+# endif
#endif
return 0;
diff --git a/nptl/sysdeps/sh/tcb-offsets.sym b/nptl/sysdeps/sh/tcb-offsets.sym
index 3386f1d..940c933 100644
--- a/nptl/sysdeps/sh/tcb-offsets.sym
+++ b/nptl/sysdeps/sh/tcb-offsets.sym
@@ -1,5 +1,5 @@
#include <sysdep.h>
#include <tls.h>
-MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads)
+MULTIPLE_THREADS_OFFSET ((char *) &p_multiple_threads ((struct pthread *)0) - (char *) 0)
TLS_PRE_TCB_SIZE sizeof (struct pthread)
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
index 667abce..930cc14 100644
--- a/nptl/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
@@ -101,7 +101,7 @@ __syscall_error_##args: \
# ifndef __ASSEMBLER__
# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0, 1)
+ __builtin_expect (p_multiple_threads (THREAD_SELF) == 0, 1)
# else
# define SINGLE_THREAD_P \
adds r14 = MULTIPLE_THREADS_OFFSET, r13 ;; ld4 r14 = [r14] ;; cmp4.ne p6, p7 = 0, r14
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c b/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c
index bcbcdd7..e811ad7 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c
@@ -19,7 +19,7 @@
/* Value passed to 'clone' for initialization of the thread register. */
#define TLS_VALUE ((void *) (pd) \
- + TLS_TCB_OFFSET + TLS_TCB_SIZE + TLS_PRE_TCB_SIZE)
+ + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE)
/* Get the real implementation. */
#include <nptl/sysdeps/pthread/createthread.c>
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
index d256f8d..f82addb 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
@@ -86,8 +86,7 @@
# ifndef __ASSEMBLER__
# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.multiple_threads) == 0, 1)
+ __builtin_expect (p_multiple_threads (THREAD_SELF) == 0, 1)
# else
# define SINGLE_THREAD_P \
lwz 10,MULTIPLE_THREADS_OFFSET(2); \
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
index 5483586..00dc3a2 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
@@ -86,8 +86,7 @@
# ifndef __ASSEMBLER__
# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.multiple_threads) == 0, 1)
+ __builtin_expect (p_multiple_threads (THREAD_SELF) == 0, 1)
# else
# define SINGLE_THREAD_P \
lwz 10,MULTIPLE_THREADS_OFFSET(13); \
diff --git a/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
index 16f8ad5..10189a4 100644
--- a/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
@@ -117,8 +117,7 @@
# ifndef __ASSEMBLER__
# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.multiple_threads) == 0, 1)
+ __builtin_expect (p_multiple_threads (THREAD_SELF) == 0, 1)
# else
# define SINGLE_THREAD_P \
stc gbr,r0; \