diff options
Diffstat (limited to 'sysdeps/mach/pt-timedblock.c')
-rw-r--r-- | sysdeps/mach/pt-timedblock.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/sysdeps/mach/pt-timedblock.c b/sysdeps/mach/pt-timedblock.c index 88beaa2..d72ef73 100644 --- a/sysdeps/mach/pt-timedblock.c +++ b/sysdeps/mach/pt-timedblock.c @@ -36,27 +36,26 @@ __pthread_timedblock (struct __pthread *thread, 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, |