remove compatibility code for handling CLOCK_MONOTONIC and handle it in the
syscall directly.
This commit is contained in:
parent
fe4bb79f58
commit
cdce479a47
|
@ -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 <sys/cdefs.h>
|
||||
__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) {
|
||||
|
|
|
@ -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 <sys/cdefs.h>
|
||||
__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 <sys/param.h>
|
||||
#include <sys/syscall.h>
|
||||
|
@ -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
|
||||
|
|
|
@ -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 <sys/cdefs.h>
|
||||
__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 <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
@ -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);
|
||||
|
|
|
@ -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 <sys/cdefs.h>
|
||||
__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 <sys/types.h>
|
||||
#include <sys/lwpctl.h>
|
||||
|
@ -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--;
|
||||
|
|
Loading…
Reference in New Issue