diff --git a/lib/libpthread/pthread.c b/lib/libpthread/pthread.c index 8512358b7041..5f22ed087953 100644 --- a/lib/libpthread/pthread.c +++ b/lib/libpthread/pthread.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread.c,v 1.143 2013/03/21 16:49:11 christos Exp $ */ +/* $NetBSD: pthread.c,v 1.144 2014/01/31 20:44:01 christos Exp $ */ /*- * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: pthread.c,v 1.143 2013/03/21 16:49:11 christos Exp $"); +__RCSID("$NetBSD: pthread.c,v 1.144 2014/01/31 20:44:01 christos Exp $"); #define __EXPOSE_STACK 1 @@ -1177,7 +1177,8 @@ pthread__park(pthread_t self, pthread_mutex_t *lock, * If we deferred unparking a thread, arrange to * have _lwp_park() restart it before blocking. */ - error = _lwp_park(abstime, self->pt_unpark, hint, hint); + error = _lwp_park(CLOCK_REALTIME, TIMER_ABSTIME, abstime, + self->pt_unpark, hint, hint); self->pt_unpark = 0; if (error != 0) { switch (rv = errno) { diff --git a/lib/libpthread/pthread_compat.c b/lib/libpthread/pthread_compat.c index 415db4c2c4e9..97a4bc0ef975 100644 --- a/lib/libpthread/pthread_compat.c +++ b/lib/libpthread/pthread_compat.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_compat.c,v 1.2 2008/10/08 08:27:07 ad Exp $ */ +/* $NetBSD: pthread_compat.c,v 1.3 2014/01/31 20:44:01 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__RCSID("$NetBSD: pthread_compat.c,v 1.2 2008/10/08 08:27:07 ad Exp $"); +__RCSID("$NetBSD: pthread_compat.c,v 1.3 2014/01/31 20:44:01 christos Exp $"); #include #include @@ -85,10 +85,11 @@ _lwp_detach(lwpid_t a) } int -_lwp_park(const struct timespec *a, lwpid_t b, const void *c, const void *d) +_lwp_park(clockid_t a, int b, const struct timespec *c, lwpid_t d, + const void *e, const void *f) { - return syscall(SYS__lwp_park, a, b, c, d); + return syscall(SYS____lwp_park60, a, b, c, d, e, f); } int diff --git a/lib/libpthread/pthread_cond.c b/lib/libpthread/pthread_cond.c index 22e3bc8738e2..4be884a1395e 100644 --- a/lib/libpthread/pthread_cond.c +++ b/lib/libpthread/pthread_cond.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_cond.c,v 1.62 2014/01/31 19:22:00 christos Exp $ */ +/* $NetBSD: pthread_cond.c,v 1.63 2014/01/31 20:44:01 christos Exp $ */ /*- * Copyright (c) 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -46,7 +46,7 @@ */ #include -__RCSID("$NetBSD: pthread_cond.c,v 1.62 2014/01/31 19:22:00 christos Exp $"); +__RCSID("$NetBSD: pthread_cond.c,v 1.63 2014/01/31 20:44:01 christos Exp $"); #include #include @@ -131,7 +131,7 @@ pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, { pthread_t self; int retval; - struct timespec mono; + clockid_t clkid = pthread_cond_getclock(cond); if (__predict_false(__uselibcstub)) return __libc_cond_timedwait_stub(cond, mutex, abstime); @@ -142,25 +142,6 @@ pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, mutex->ptm_magic == _PT_MUTEX_MAGIC); pthread__error(EPERM, "Mutex not locked in condition wait", mutex->ptm_owner != NULL); - if (abstime != NULL) { - /* - * XXX: This should be done in the kernel to avoid - * extra system calls! - */ - if (pthread_cond_getclock(cond) == CLOCK_MONOTONIC) { - struct timespec real; - if (clock_gettime(CLOCK_REALTIME, &real) == -1 || - clock_gettime(CLOCK_MONOTONIC, &mono) == -1) - return errno; - timespecsub(abstime, &mono, &mono); - timespecadd(&mono, &real, &mono); - abstime = &mono; - } - pthread__error(EINVAL, "Invalid wait time", - (abstime->tv_sec >= 0) && - (abstime->tv_nsec >= 0) && - (abstime->tv_nsec < 1000000000)); - } self = pthread__self(); @@ -185,8 +166,8 @@ pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, self->pt_willpark = 0; self->pt_blocking++; do { - retval = _lwp_park(abstime, self->pt_unpark, - __UNVOLATILE(&mutex->ptm_waiters), + retval = _lwp_park(clkid, TIMER_ABSTIME, abstime, + self->pt_unpark, __UNVOLATILE(&mutex->ptm_waiters), __UNVOLATILE(&mutex->ptm_waiters)); self->pt_unpark = 0; } while (retval == -1 && errno == ESRCH); diff --git a/lib/libpthread/pthread_mutex.c b/lib/libpthread/pthread_mutex.c index 7109386e0869..d52790e1a746 100644 --- a/lib/libpthread/pthread_mutex.c +++ b/lib/libpthread/pthread_mutex.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_mutex.c,v 1.57 2014/01/31 19:22:00 christos Exp $ */ +/* $NetBSD: pthread_mutex.c,v 1.58 2014/01/31 20:44:01 christos Exp $ */ /*- * Copyright (c) 2001, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -47,7 +47,7 @@ */ #include -__RCSID("$NetBSD: pthread_mutex.c,v 1.57 2014/01/31 19:22:00 christos Exp $"); +__RCSID("$NetBSD: pthread_mutex.c,v 1.58 2014/01/31 20:44:01 christos Exp $"); #include #include @@ -330,8 +330,8 @@ pthread__mutex_lock_slow(pthread_mutex_t *ptm) */ while (self->pt_mutexwait) { self->pt_blocking++; - (void)_lwp_park(NULL, self->pt_unpark, - __UNVOLATILE(&ptm->ptm_waiters), + (void)_lwp_park(CLOCK_REALTIME, TIMER_ABSTIME, NULL, + self->pt_unpark, __UNVOLATILE(&ptm->ptm_waiters), __UNVOLATILE(&ptm->ptm_waiters)); self->pt_unpark = 0; self->pt_blocking--;