Module Name: src
Committed By: christos
Date: Fri Jan 31 20:44:01 UTC 2014
Modified Files:
src/lib/libpthread: pthread.c pthread_compat.c pthread_cond.c
pthread_mutex.c
Log Message:
remove compatibility code for handling CLOCK_MONOTONIC and handle it in the
syscall directly.
To generate a diff of this commit:
cvs rdiff -u -r1.143 -r1.144 src/lib/libpthread/pthread.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libpthread/pthread_compat.c
cvs rdiff -u -r1.62 -r1.63 src/lib/libpthread/pthread_cond.c
cvs rdiff -u -r1.57 -r1.58 src/lib/libpthread/pthread_mutex.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libpthread/pthread.c
diff -u src/lib/libpthread/pthread.c:1.143 src/lib/libpthread/pthread.c:1.144
--- src/lib/libpthread/pthread.c:1.143 Thu Mar 21 12:49:11 2013
+++ src/lib/libpthread/pthread.c Fri Jan 31 15:44:01 2014
@@ -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_mu
* 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) {
Index: src/lib/libpthread/pthread_compat.c
diff -u src/lib/libpthread/pthread_compat.c:1.2 src/lib/libpthread/pthread_compat.c:1.3
--- src/lib/libpthread/pthread_compat.c:1.2 Wed Oct 8 04:27:07 2008
+++ src/lib/libpthread/pthread_compat.c Fri Jan 31 15:44:01 2014
@@ -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
Index: src/lib/libpthread/pthread_cond.c
diff -u src/lib/libpthread/pthread_cond.c:1.62 src/lib/libpthread/pthread_cond.c:1.63
--- src/lib/libpthread/pthread_cond.c:1.62 Fri Jan 31 14:22:00 2014
+++ src/lib/libpthread/pthread_cond.c Fri Jan 31 15:44:01 2014
@@ -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 *c
{
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 *c
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 *c
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);
Index: src/lib/libpthread/pthread_mutex.c
diff -u src/lib/libpthread/pthread_mutex.c:1.57 src/lib/libpthread/pthread_mutex.c:1.58
--- src/lib/libpthread/pthread_mutex.c:1.57 Fri Jan 31 14:22:00 2014
+++ src/lib/libpthread/pthread_mutex.c Fri Jan 31 15:44:01 2014
@@ -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
*/
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--;