diff options
Diffstat (limited to 'sysdeps/mach')
-rw-r--r-- | sysdeps/mach/hurd/Implies | 1 | ||||
-rw-r--r-- | sysdeps/mach/hurd/i386/pt-machdep.c (renamed from sysdeps/mach/hurd/ia32/pt-machdep.c) | 0 | ||||
-rw-r--r-- | sysdeps/mach/hurd/i386/pt-setup.c (renamed from sysdeps/mach/hurd/ia32/pt-setup.c) | 12 | ||||
-rw-r--r-- | sysdeps/mach/hurd/pt-sysdep.c | 7 | ||||
-rw-r--r-- | sysdeps/mach/hurd/pt-sysdep.h | 6 | ||||
-rw-r--r-- | sysdeps/mach/pt-timedblock.c | 16 |
6 files changed, 20 insertions, 22 deletions
diff --git a/sysdeps/mach/hurd/Implies b/sysdeps/mach/hurd/Implies new file mode 100644 index 0000000..16b8348 --- /dev/null +++ b/sysdeps/mach/hurd/Implies @@ -0,0 +1 @@ +hurd diff --git a/sysdeps/mach/hurd/ia32/pt-machdep.c b/sysdeps/mach/hurd/i386/pt-machdep.c index f3c8cf5..f3c8cf5 100644 --- a/sysdeps/mach/hurd/ia32/pt-machdep.c +++ b/sysdeps/mach/hurd/i386/pt-machdep.c diff --git a/sysdeps/mach/hurd/ia32/pt-setup.c b/sysdeps/mach/hurd/i386/pt-setup.c index 5420dc8..73fd43d 100644 --- a/sysdeps/mach/hurd/ia32/pt-setup.c +++ b/sysdeps/mach/hurd/i386/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 5e07006..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); @@ -45,14 +47,13 @@ init_routine (void) int err; /* Initialize the library. */ - __pthread_initialize (); + __pthread_init (); /* Create the pthread structure for the main thread (i.e. us). */ 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 (); \ diff --git a/sysdeps/mach/pt-timedblock.c b/sysdeps/mach/pt-timedblock.c index 6f54726..d72ef73 100644 --- a/sysdeps/mach/pt-timedblock.c +++ b/sysdeps/mach/pt-timedblock.c @@ -30,32 +30,32 @@ /* Block THREAD. */ error_t __pthread_timedblock (struct __pthread *thread, - const struct timespec *abstime) + const struct timespec *abstime, + clockid_t clock_id) { error_t err; mach_msg_header_t msg; mach_msg_timeout_t timeout; - struct timeval now; + struct timespec now; /* We have an absolute time and now we have to convert it to a relative time. Arg. */ - err = gettimeofday(&now, NULL); + err = clock_gettime (clock_id, &now); assert (! err); if (now.tv_sec > abstime->tv_sec || (now.tv_sec == abstime->tv_sec - && now.tv_usec > ((abstime->tv_nsec + 999) / 1000))) + && now.tv_nsec > abstime->tv_nsec)) return ETIMEDOUT; timeout = (abstime->tv_sec - now.tv_sec) * 1000; - if (((abstime->tv_nsec + 999) / 1000) >= now.tv_usec) - timeout += (((abstime->tv_nsec + 999) / 1000) - now.tv_usec + 999) / 1000; + if (abstime->tv_nsec >= now.tv_nsec) + timeout += (abstime->tv_nsec - now.tv_nsec + 999999) / 1000000; else /* Need to do a carry. */ - timeout -= (now.tv_usec + 999) / 1000 - - ((abstime->tv_nsec + 999999) / 1000000); + timeout -= (now.tv_nsec - abstime->tv_nsec + 999999) / 1000000; err = __mach_msg (&msg, MACH_RCV_MSG | MACH_RCV_TIMEOUT, 0, sizeof msg, thread->wakeupmsg.msgh_remote_port, |