summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2012-05-25 02:33:13 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-05-25 02:33:13 +0200
commitb428baaa85c0adca9ef4884c637f289a0ab5e2d6 (patch)
tree2b886760ce40712db7282a83dcc3957bacabd42b
parent1dc7553d93bf7f48b5f767b74eab607142d77160 (diff)
parent25260994c812050a5d7addf125cdc90c911ca5c1 (diff)
Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/libpthread
-rw-r--r--pthread/pt-create.c6
-rw-r--r--pthread/pt-initialize.c7
-rw-r--r--pthread/pt-internal.h3
-rw-r--r--sysdeps/l4/hurd/ia32/pt-setup.c5
-rw-r--r--sysdeps/l4/hurd/powerpc/pt-setup.c7
-rw-r--r--sysdeps/mach/hurd/ia32/pt-setup.c12
-rw-r--r--sysdeps/mach/hurd/pt-sysdep.c5
-rw-r--r--sysdeps/mach/hurd/pt-sysdep.h6
8 files changed, 26 insertions, 25 deletions
diff --git a/pthread/pt-create.c b/pthread/pt-create.c
index ca6b66c..4d81a95 100644
--- a/pthread/pt-create.c
+++ b/pthread/pt-create.c
@@ -38,8 +38,12 @@ __atomic_t __pthread_total;
/* The entry-point for new threads. */
static void
-entry_point (void *(*start_routine)(void *), void *arg)
+entry_point (struct __pthread *self, void *(*start_routine)(void *), void *arg)
{
+#ifdef ENABLE_TLS
+ ___pthread_self = self;
+#endif
+
#ifdef HAVE_USELOCALE
/* A fresh thread needs to be bound to the global locale. */
uselocale (LC_GLOBAL_LOCALE);
diff --git a/pthread/pt-initialize.c b/pthread/pt-initialize.c
index 39f1aed..831a63d 100644
--- a/pthread/pt-initialize.c
+++ b/pthread/pt-initialize.c
@@ -29,7 +29,6 @@
DEFINE_HOOK (__pthread_init, (void));
#ifdef IS_IN_libpthread
-#ifdef SHARED
static const struct pthread_functions pthread_functions =
{
.ptr_pthread_attr_destroy = __pthread_attr_destroy,
@@ -66,10 +65,6 @@ static const struct pthread_functions pthread_functions =
.ptr_pthread_setcanceltype = __pthread_setcanceltype,
.ptr___pthread_get_cleanup_stack = __pthread_get_cleanup_stack,
};
-# define ptr_pthread_functions &pthread_functions
-#else
-# define ptr_pthread_functions NULL
-#endif
#endif /* IS_IN_libpthread */
/* Initialize the pthreads library. */
@@ -77,7 +72,7 @@ void
__pthread_init (void)
{
#ifdef IS_IN_libpthread
- __libc_pthread_init(ptr_pthread_functions);
+ __libc_pthread_init(&pthread_functions);
#endif
RUN_HOOK (__pthread_init, ());
}
diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h
index a1da377..f5766e9 100644
--- a/pthread/pt-internal.h
+++ b/pthread/pt-internal.h
@@ -217,7 +217,8 @@ extern void __pthread_stack_dealloc (void *stackaddr, size_t stacksize);
/* Setup thread THREAD's context. */
extern int __pthread_setup (struct __pthread *__restrict thread,
- void (*entry_point)(void *(*)(void *),
+ void (*entry_point)(struct __pthread *,
+ void *(*)(void *),
void *),
void *(*start_routine)(void *),
void *__restrict arg);
diff --git a/sysdeps/l4/hurd/ia32/pt-setup.c b/sysdeps/l4/hurd/ia32/pt-setup.c
index 579905c..de7359c 100644
--- a/sysdeps/l4/hurd/ia32/pt-setup.c
+++ b/sysdeps/l4/hurd/ia32/pt-setup.c
@@ -65,7 +65,7 @@ __pthread_entry_point:\n\
static void *
stack_setup (struct __pthread *thread,
void *(*start_routine)(void *), void *arg,
- void (*entry_point)(void *(*)(void *), void *))
+ void (*entry_point)(struct __pthread *, void *(*)(void *), void *))
{
uintptr_t *top;
@@ -80,6 +80,7 @@ stack_setup (struct __pthread *thread,
/* Set up call frame. */
*--top = (uintptr_t) arg; /* Argument to START_ROUTINE. */
*--top = (uintptr_t) start_routine;
+ *--top = (uintptr_t) thread;
*--top = 0; /* Fake return address. */
*--top = (uintptr_t) entry_point;
}
@@ -89,7 +90,7 @@ stack_setup (struct __pthread *thread,
int
__pthread_setup (struct __pthread *thread,
- void (*entry_point)(void *(*)(void *), void *),
+ void (*entry_point)(struct __pthread *, void *(*)(void *), void *),
void *(*start_routine)(void *), void *arg)
{
thread->mcontext.pc = (void *) &_pthread_entry_point;
diff --git a/sysdeps/l4/hurd/powerpc/pt-setup.c b/sysdeps/l4/hurd/powerpc/pt-setup.c
index d3cf4ec..d309216 100644
--- a/sysdeps/l4/hurd/powerpc/pt-setup.c
+++ b/sysdeps/l4/hurd/powerpc/pt-setup.c
@@ -28,6 +28,7 @@
struct start_info
{
void (*entry_point) (void *(*)(void *), void *);
+ struct __pthread *self;
void *(*start_routine) (void *);
void *arg;
};
@@ -41,6 +42,7 @@ first_entry_1: ;\
lwz 0, 0(1) ;\
lwz 3, 4(1) ;\
lwz 4, 8(1) ;\
+ lwz 5, 12(1) ;\
mtctr 0 ;\
bctrl ;\
");
@@ -51,7 +53,7 @@ first_entry_1: ;\
opportunity to install THREAD in our utcb. */
static void *
stack_setup (struct __pthread *thread,
- void (*entry_point)(void *(*)(void *), void *),
+ void (*entry_point)(struct __pthread *, void *(*)(void *), void *),
void *(*start_routine)(void *), void *arg)
{
l4_word_t *top;
@@ -68,6 +70,7 @@ stack_setup (struct __pthread *thread,
struct start_info *info = ((struct start_info *) top) - 1;
info->entry_point = entry_point;
+ info->self = thread;
info->start_routine = start_routine;
info->arg = arg;
return (void *) info;
@@ -77,7 +80,7 @@ stack_setup (struct __pthread *thread,
int
__pthread_setup (struct __pthread *thread,
- void (*entry_point)(void *(*)(void *), void *),
+ void (*entry_point)(struct __pthread *, void *(*)(void *), void *),
void *(*start_routine)(void *), void *arg)
{
thread->mcontext.pc = first_entry_1;
diff --git a/sysdeps/mach/hurd/ia32/pt-setup.c b/sysdeps/mach/hurd/ia32/pt-setup.c
index 5420dc8..73fd43d 100644
--- a/sysdeps/mach/hurd/ia32/pt-setup.c
+++ b/sysdeps/mach/hurd/ia32/pt-setup.c
@@ -57,16 +57,14 @@ stack_setup (struct __pthread *thread,
/* Next, make room for the TSDs. */
top -= __hurd_threadvar_max;
- /* Save the self pointer. */
- top[_HURD_THREADVAR_THREAD] = (uintptr_t) thread;
-
if (start_routine)
{
/* And then the call frame. */
- top -= 2;
+ top -= 3;
top = (uintptr_t *) ((uintptr_t) top & ~0xf);
- top[1] = (uintptr_t) arg; /* Argument to START_ROUTINE. */
- top[0] = (uintptr_t) start_routine;
+ top[2] = (uintptr_t) arg; /* Argument to START_ROUTINE. */
+ top[1] = (uintptr_t) start_routine;
+ top[0] = (uintptr_t) thread;
*--top = 0; /* Fake return address. */
}
@@ -82,7 +80,7 @@ stack_setup (struct __pthread *thread,
int
__pthread_setup (struct __pthread *thread,
- void (*entry_point)(void *(*)(void *), void *),
+ void (*entry_point)(struct __pthread *, void *(*)(void *), void *),
void *(*start_routine)(void *), void *arg)
{
error_t err;
diff --git a/sysdeps/mach/hurd/pt-sysdep.c b/sysdeps/mach/hurd/pt-sysdep.c
index 95a4d36..f40fee5 100644
--- a/sysdeps/mach/hurd/pt-sysdep.c
+++ b/sysdeps/mach/hurd/pt-sysdep.c
@@ -28,6 +28,8 @@
#include <pt-internal.h>
+__thread struct __pthread *___pthread_self;
+
/* Forward. */
static void *init_routine (void);
@@ -51,8 +53,7 @@ init_routine (void)
err = __pthread_create_internal (&thread, 0, 0, 0);
assert_perror (err);
- ((void **) (__hurd_threadvar_stack_offset))[_HURD_THREADVAR_THREAD]
- = thread;
+ ___pthread_self = thread;
/* Decrease the number of threads, to take into account that the
signal thread (which will be created by the glibc startup code
diff --git a/sysdeps/mach/hurd/pt-sysdep.h b/sysdeps/mach/hurd/pt-sysdep.h
index 13e235d..bec1b40 100644
--- a/sysdeps/mach/hurd/pt-sysdep.h
+++ b/sysdeps/mach/hurd/pt-sysdep.h
@@ -35,15 +35,13 @@
mach_msg_header_t wakeupmsg; \
int have_kernel_resources;
-#define _HURD_THREADVAR_THREAD _HURD_THREADVAR_DYNAMIC_USER
-
+extern __thread struct __pthread *___pthread_self;
#define _pthread_self() \
({ \
struct __pthread *thread; \
\
assert (__pthread_threads); \
- thread = *(struct __pthread **) \
- __hurd_threadvar_location (_HURD_THREADVAR_THREAD); \
+ thread = ___pthread_self; \
\
assert (thread); \
assert (({ mach_port_t ktid = __mach_thread_self (); \