aboutsummaryrefslogtreecommitdiff
path: root/linuxthreads/sysdeps
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2003-03-02 11:45:12 +0000
committerRoland McGrath <roland@gnu.org>2003-03-02 11:45:12 +0000
commitbb0ddc2f1eca652aa8af56825b2ba3182498cc5a (patch)
tree8b03305facff745ff0bd14c50e811dfd77cef343 /linuxthreads/sysdeps
parent3093b1c70cd227c3329d2bbb77cd59ce2cbdcbd4 (diff)
downloadglibc-bb0ddc2f1eca652aa8af56825b2ba3182498cc5a.zip
glibc-bb0ddc2f1eca652aa8af56825b2ba3182498cc5a.tar.gz
glibc-bb0ddc2f1eca652aa8af56825b2ba3182498cc5a.tar.bz2
* sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_fixup_plt):
Don't use weak_extern for dl_rtld_map. Instead check only if [SHARED]. (elf_machine_rela): Clean up. * sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela): Clean up. PowerPC TLS support contributed by Paul Mackerras <paulus@samba.org>. * sysdeps/powerpc/powerpc32/elf/configure.in: New file. * sysdeps/powerpc/powerpc32/elf/configure: New generated file. * elf/tls-macros.h [__powerpc__ && !__powerpc64__] (TLS_LE, TLS_IE, TLS_LD, TLS_GD): Define them. * sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela): Support new relocs for TLS. * sysdeps/powerpc/dl-tls.h (TLS_TP_OFFSET, TLS_DTV_OFFSET): Move these macros out of [SHARED]. (TLS_TPREL_VALUE, TLS_DTPREL_VALUE): New macros. * elf/elf.h: Define R_PPC_* relocs for TLS support. Clean up R_PPC64_* macro definition comments.
Diffstat (limited to 'linuxthreads/sysdeps')
-rw-r--r--linuxthreads/sysdeps/ia64/tcb-offsets.sym2
-rw-r--r--linuxthreads/sysdeps/ia64/tls.h2
-rw-r--r--linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h12
-rw-r--r--linuxthreads/sysdeps/powerpc/tcb-offsets.sym22
-rw-r--r--linuxthreads/sysdeps/powerpc/tls.h63
-rw-r--r--linuxthreads/sysdeps/sh/tcb-offsets.sym2
-rw-r--r--linuxthreads/sysdeps/sh/tls.h2
-rw-r--r--linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h3
-rw-r--r--linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h3
-rw-r--r--linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h3
10 files changed, 75 insertions, 39 deletions
diff --git a/linuxthreads/sysdeps/ia64/tcb-offsets.sym b/linuxthreads/sysdeps/ia64/tcb-offsets.sym
index 2b677f5..f7793f7 100644
--- a/linuxthreads/sysdeps/ia64/tcb-offsets.sym
+++ b/linuxthreads/sysdeps/ia64/tcb-offsets.sym
@@ -3,7 +3,7 @@
--
#ifdef USE_TLS
-MULTIPLE_THREADS_OFFSET offsetof (struct _pthread_descr_struct, p_header.data.multiple_threads) - sizeof (struct _pthread_descr_struct)
+MULTIPLE_THREADS_OFFSET offsetof (struct _pthread_descr_struct, p_multiple_threads) - sizeof (struct _pthread_descr_struct)
#else
MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
#endif
diff --git a/linuxthreads/sysdeps/ia64/tls.h b/linuxthreads/sysdeps/ia64/tls.h
index 238ea08..7aec4f4 100644
--- a/linuxthreads/sysdeps/ia64/tls.h
+++ b/linuxthreads/sysdeps/ia64/tls.h
@@ -98,6 +98,8 @@ typedef struct
# define INIT_THREAD_SELF(descr, nr) \
(__thread_self = (struct _pthread_descr_struct *)(descr) + 1)
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+
/* Get the thread descriptor definition. */
# include <linuxthreads/descr.h>
diff --git a/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h b/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h
index a3dc26f..e3a153a 100644
--- a/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h
+++ b/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h
@@ -1,6 +1,6 @@
/* Machine-dependent pthreads configuration and inline functions.
powerpc version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 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
@@ -57,6 +57,16 @@ register struct _pthread_descr_struct *__thread_self __asm__("r13");
/* Initialize the thread-unique value. */
#define INIT_THREAD_SELF(descr, nr) (__thread_self = (descr))
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) \
+ ((void) (descr), THREAD_SELF->member)
+#define THREAD_GETMEM_NC(descr, member) \
+ ((void) (descr), THREAD_SELF->member)
+#define THREAD_SETMEM(descr, member, value) \
+ ((void) (descr), THREAD_SELF->member = (value))
+#define THREAD_SETMEM_NC(descr, member, value) \
+ ((void) (descr), THREAD_SELF->member = (value))
+
/* Compare-and-swap for semaphores. */
/* note that test-and-set(x) is the same as !compare-and-swap(x, 0, 1) */
diff --git a/linuxthreads/sysdeps/powerpc/tcb-offsets.sym b/linuxthreads/sysdeps/powerpc/tcb-offsets.sym
index aee6be2..bb4226f 100644
--- a/linuxthreads/sysdeps/powerpc/tcb-offsets.sym
+++ b/linuxthreads/sysdeps/powerpc/tcb-offsets.sym
@@ -1,4 +1,24 @@
#include <sysdep.h>
#include <tls.h>
-MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
+--
+
+-- This could go into powerpc32/ instead and conditionalize #include of it.
+#ifndef __powerpc64__
+
+# ifdef USE_TLS
+
+-- 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->p_##mem - (void *) 0)
+
+# else
+
+# define thread_offsetof(mem) offsetof (tcbhead_t, mem)
+
+# endif
+
+MULTIPLE_THREADS_OFFSET thread_offsetof (multiple_threads)
+
+#endif
diff --git a/linuxthreads/sysdeps/powerpc/tls.h b/linuxthreads/sysdeps/powerpc/tls.h
index 1c34a3b..d946d06 100644
--- a/linuxthreads/sysdeps/powerpc/tls.h
+++ b/linuxthreads/sysdeps/powerpc/tls.h
@@ -32,15 +32,6 @@ typedef union dtv
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;
-
#else /* __ASSEMBLER__ */
# include <tcb-offsets.h>
#endif /* __ASSEMBLER__ */
@@ -52,6 +43,14 @@ typedef struct
# ifndef __ASSEMBLER__
+/* This layout is actually wholly private and not affected by the ABI.
+ Nor does it overlap the pthread data structure, so we need nothing
+ extra here at all. */
+typedef struct
+{
+ dtv_t *dtv;
+} tcbhead_t;
+
/* This is the size of the initial TCB. */
# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
@@ -67,12 +66,12 @@ typedef struct
/* This is the size we need before TCB. */
# define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
-/* The following assumes that TP (R13) is points to the end of the
+/* The following assumes that TP (R2 or R13) is points to the end of the
TCB + 0x7000 (per the ABI). This implies that TCB address is
- R13-(TLS_TCB_SIZE + 0x7000). As we define TLS_DTV_AT_TP we can
+ TP-(TLS_TCB_SIZE + 0x7000). As we define TLS_DTV_AT_TP we can
assume that the pthread_descr is allocated immediately ahead of the
TCB. This implies that the pthread_descr address is
- R13-(TLS_PRE_TCB_SIZE + TLS_TCB_SIZE + 0x7000). */
+ TP-(TLS_PRE_TCB_SIZE + TLS_TCB_SIZE + 0x7000). */
# define TLS_TCB_OFFSET 0x7000
/* The DTV is allocated at the TP; the TCB is placed elsewhere. */
@@ -99,7 +98,7 @@ typedef struct
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, 0)
+ (__thread_register = (void *) (TCBP) + TLS_TCB_OFFSET + TLS_TCB_SIZE, NULL)
/* Return the address of the dtv for the current thread. */
# define THREAD_DTV() \
@@ -116,30 +115,36 @@ typedef struct
(__thread_register = ((void *) (DESCR) \
+ TLS_TCB_OFFSET + TLS_TCB_SIZE + TLS_PRE_TCB_SIZE))
+/* Make sure we have the p_multiple_threads member in the thread structure.
+ See below. */
+# ifndef __powerpc64__
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+# endif
+
/* Get the thread descriptor definition. */
# include <linuxthreads/descr.h>
-/* Generic bits of LinuxThreads may call these macros with
- DESCR set to NULL. We are expected to be able to reference
- the "current" value. */
-
-# define THREAD_GETMEM(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
-# define THREAD_SETMEM(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
-
-#define THREAD_GETMEM_NC(descr, member) THREAD_GETMEM (descr, member)
-#define THREAD_SETMEM_NC(descr, member, value) \
- THREAD_SETMEM ((descr), member, (value))
-
# endif /* __ASSEMBLER__ */
-#else /* Not HAVE_TLS_SUPPORT. */
+#elif !defined __ASSEMBLER__ && !defined __powerpc64__
+
+/* This overlaps the start of the pthread_descr. On PPC32, system
+ calls and such use this to find the multiple_threads flag and need
+ to use the same offset relative to the thread register in both
+ single-threaded and multi-threaded code. On PPC64, the global
+ variable is always used, so single-threaded code without TLS
+ never needs to initialize the thread register at all. */
+typedef struct
+{
+ void *tcb; /* Never used. */
+ dtv_t *dtv; /* Never used. */
+ void *self; /* Used only if multithreaded, and rarely. */
+ int multiple_threads; /* Only this member is really used. */
+} tcbhead_t;
#define NONTLS_INIT_TP \
do { \
- static const tcbhead_t nontls_init_tp \
- = { .multiple_threads = 0 }; \
+ static const tcbhead_t nontls_init_tp = { .multiple_threads = 0 }; \
__thread_self = (__typeof (__thread_self)) &nontls_init_tp; \
} while (0)
diff --git a/linuxthreads/sysdeps/sh/tcb-offsets.sym b/linuxthreads/sysdeps/sh/tcb-offsets.sym
index d74292b..328eb05 100644
--- a/linuxthreads/sysdeps/sh/tcb-offsets.sym
+++ b/linuxthreads/sysdeps/sh/tcb-offsets.sym
@@ -3,7 +3,7 @@
--
#ifdef USE_TLS
-MULTIPLE_THREADS_OFFSET offsetof (struct _pthread_descr_struct, p_header.data.multiple_threads)
+MULTIPLE_THREADS_OFFSET offsetof (struct _pthread_descr_struct, p_multiple_threads)
TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
#else
MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
diff --git a/linuxthreads/sysdeps/sh/tls.h b/linuxthreads/sysdeps/sh/tls.h
index af67a8e..17a247c 100644
--- a/linuxthreads/sysdeps/sh/tls.h
+++ b/linuxthreads/sysdeps/sh/tls.h
@@ -112,6 +112,8 @@ typedef struct
__asm __volatile ("ldc %0,gbr" : : "r" (__self + 1)); \
0; })
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+
/* Get the thread descriptor definition. This must be after the
the definition of THREAD_SELF for TLS. */
# include <linuxthreads/descr.h>
diff --git a/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h b/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
index ec94517..af45b19 100644
--- a/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
+++ b/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
@@ -101,8 +101,7 @@ __syscall_error_##args: \
# ifndef __ASSEMBLER__
# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- p_header.data.multiple_threads) == 0, 1)
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 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/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h b/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
index 155ea47..2d191d1 100644
--- a/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
+++ b/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
@@ -85,8 +85,7 @@
# ifndef __ASSEMBLER__
# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- p_header.data.multiple_threads) == 0, 1)
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 0, 1)
# else
# define SINGLE_THREAD_P \
lwz 10,MULTIPLE_THREADS_OFFSET(2); \
diff --git a/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h b/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
index 57db351..e6d0cca 100644
--- a/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
+++ b/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
@@ -121,8 +121,7 @@
# ifndef __ASSEMBLER__
# if defined FLOATING_STACKS && USE___THREAD && defined PIC
# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- p_header.data.multiple_threads) == 0, 1)
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 0, 1)
# else
extern int __local_multiple_threads attribute_hidden;
# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)