summaryrefslogtreecommitdiff
path: root/sysdeps/mach
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2012-04-27 01:32:54 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-04-27 01:37:36 +0000
commit25260994c812050a5d7addf125cdc90c911ca5c1 (patch)
tree255b2ba5ba5b799b1a5f23aef17d75534103de0a /sysdeps/mach
parente84c82a43e671c7506401936ac097b55d0fb47bf (diff)
Store self in __thread variable instead of threadvar
* sysdeps/mach/hurd/pt-sysdep.h (_HURD_THREADVAR_THREAD): Remove macro. (___pthread_self): Declare new __thread variable. (_pthread_self): Take self pointer from ___pthread_self instead of threadvar. * sysdeps/mach/hurd/pt-sysdep.c (___pthread_self): Define new __thread variable. (init_routine): Set ___pthread_self to initial thread structure. * pthread/pt-internal.h (__pthread_setup): Add `self' parameter to `entry_point' parameter. * pthread/pt-create.c (entry_point): Add `self' parameter. Store it in ___pthread_self. * sysdeps/l4/hurd/ia32/pt-setup.c (stack_setup): Add `self parameter to `entry_point' parameter. Pass it the `thread' parameter. (__pthread_setup): Likewise. * sysdeps/l4/hurd/powerpc/pt-setup.c (struct start_info): Add `self' field. (first_entry_1): Pass `self' parameter. (stack_setup): Add `self' parameter to `entry_point' parameter, pass it the `thread' parameter. (__pthread_setup): Likewise. * sysdeps/mach/hurd/ia32/pt-setup.c (stack_setup): Pass `thread' parameter to the start routine. (stack_setup): Add `self' parameter to `entry_point' paramter.
Diffstat (limited to 'sysdeps/mach')
-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
3 files changed, 10 insertions, 13 deletions
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 (); \