summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPino Toscano <toscano.pino@tiscali.it>2012-04-22 00:38:26 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-04-22 01:20:02 +0200
commit69e89a859882e4f675dd5491edc969159d8a4002 (patch)
tree568261e126d4a589e3891fa601b2e76b62766c71
parentdbaf5693972d2cbfad0ad48b966e5693b770127e (diff)
__pthread_timedblock: switch to clock_gettime
Use `clock_gettime' with the provided clock instead of `gettimeofday', linking to rt. * sysdeps/mach/pt-timedblock.c (__pthread_timedblock): Switch to `clock_gettime'. * Makefile [!IN_GLIBC] (LDLIBS): Link to rt. [IN_GLIBC] ($(objpfx)libpthread.so): Likewise. * Makefile.am (libpthread_a_LDADD): Likewise.
-rw-r--r--Makefile2
-rw-r--r--Makefile.am2
-rw-r--r--sysdeps/mach/pt-timedblock.c13
3 files changed, 10 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index b291177..bee4e3c 100644
--- a/Makefile
+++ b/Makefile
@@ -210,8 +210,10 @@ VPATH += $(SYSDEP_PATH)
ifeq ($(IN_GLIBC),no)
HURDLIBS = ihash
+LDLIBS = -lrt
else
LDLIBS-pthread.so = -lihash
+$(objpfx)libpthread.so: $(common-objpfx)rt/librt.so
endif
ifeq ($(IN_GLIBC),no)
diff --git a/Makefile.am b/Makefile.am
index e1c062c..36ede54 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -166,3 +166,5 @@ libpthread_a_SOURCES = pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \
sigwaitinfo.c \
signal-dispatch-lowlevel.c \
sigprocmask.c
+
+libpthread_a_LDADD = -lrt
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,