Module Name: src
Committed By: pooka
Date: Wed Nov 11 16:46:50 UTC 2009
Modified Files:
src/sys/rump/include/rump: rumpuser.h
src/sys/rump/librump/rumpkern: intr.c locks.c
src/sys/rump/librump/rumpuser: rumpuser_pth.c
Log Message:
Make rumpuser_cv_timedwait take two int64's instead timespec to
uncouple it from the timespec layout. Also, change return value
to zero for "timeout didn't expire" and non-zero for "timeout
expired". This decouples the interface from errno assignments.
To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/rump/include/rump/rumpuser.h
cvs rdiff -u -r1.20 -r1.21 src/sys/rump/librump/rumpkern/intr.c
cvs rdiff -u -r1.33 -r1.34 src/sys/rump/librump/rumpkern/locks.c
cvs rdiff -u -r1.37 -r1.38 src/sys/rump/librump/rumpuser/rumpuser_pth.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/rump/include/rump/rumpuser.h
diff -u src/sys/rump/include/rump/rumpuser.h:1.31 src/sys/rump/include/rump/rumpuser.h:1.32
--- src/sys/rump/include/rump/rumpuser.h:1.31 Sat Oct 24 11:36:59 2009
+++ src/sys/rump/include/rump/rumpuser.h Wed Nov 11 16:46:50 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser.h,v 1.31 2009/10/24 11:36:59 pooka Exp $ */
+/* $NetBSD: rumpuser.h,v 1.32 2009/11/11 16:46:50 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -142,7 +142,7 @@
void rumpuser_cv_wait(struct rumpuser_cv *, struct rumpuser_mtx *);
void rumpuser_cv_wait_nowrap(struct rumpuser_cv *, struct rumpuser_mtx *);
int rumpuser_cv_timedwait(struct rumpuser_cv *, struct rumpuser_mtx *,
- struct timespec *);
+ int64_t, int64_t);
void rumpuser_cv_signal(struct rumpuser_cv *);
void rumpuser_cv_broadcast(struct rumpuser_cv *);
int rumpuser_cv_has_waiters(struct rumpuser_cv *);
Index: src/sys/rump/librump/rumpkern/intr.c
diff -u src/sys/rump/librump/rumpkern/intr.c:1.20 src/sys/rump/librump/rumpkern/intr.c:1.21
--- src/sys/rump/librump/rumpkern/intr.c:1.20 Mon Nov 9 19:16:18 2009
+++ src/sys/rump/librump/rumpkern/intr.c Wed Nov 11 16:46:50 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.c,v 1.20 2009/11/09 19:16:18 pooka Exp $ */
+/* $NetBSD: intr.c,v 1.21 2009/11/11 16:46:50 pooka Exp $ */
/*
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.20 2009/11/09 19:16:18 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.21 2009/11/11 16:46:50 pooka Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@@ -124,7 +124,7 @@
/* wait until the next tick. XXX: what if the clock changes? */
while (rumpuser_cv_timedwait(clockcv, clockmtx,
- &curtime) != EWOULDBLOCK)
+ curtime.tv_sec, curtime.tv_nsec) == 0)
continue;
clkgen++;
Index: src/sys/rump/librump/rumpkern/locks.c
diff -u src/sys/rump/librump/rumpkern/locks.c:1.33 src/sys/rump/librump/rumpkern/locks.c:1.34
--- src/sys/rump/librump/rumpkern/locks.c:1.33 Wed Nov 4 13:32:39 2009
+++ src/sys/rump/librump/rumpkern/locks.c Wed Nov 11 16:46:50 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: locks.c,v 1.33 2009/11/04 13:32:39 pooka Exp $ */
+/* $NetBSD: locks.c,v 1.34 2009/11/11 16:46:50 pooka Exp $ */
/*
* Copyright (c) 2007, 2008 Antti Kantee. All Rights Reserved.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.33 2009/11/04 13:32:39 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.34 2009/11/11 16:46:50 pooka Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -236,7 +236,11 @@
cv_wait(cv, mtx);
return 0;
} else {
- return rumpuser_cv_timedwait(RUMPCV(cv), RUMPMTX(mtx), &ts);
+ if (rumpuser_cv_timedwait(RUMPCV(cv), RUMPMTX(mtx),
+ ts.tv_sec, ts.tv_nsec))
+ return EWOULDBLOCK;
+ else
+ return 0;
}
}
Index: src/sys/rump/librump/rumpuser/rumpuser_pth.c
diff -u src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.37 src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.38
--- src/sys/rump/librump/rumpuser/rumpuser_pth.c:1.37 Mon Nov 9 18:00:26 2009
+++ src/sys/rump/librump/rumpuser/rumpuser_pth.c Wed Nov 11 16:46:50 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_pth.c,v 1.37 2009/11/09 18:00:26 pooka Exp $ */
+/* $NetBSD: rumpuser_pth.c,v 1.38 2009/11/11 16:46:50 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth.c,v 1.37 2009/11/09 18:00:26 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.38 2009/11/11 16:46:50 pooka Exp $");
#endif /* !lint */
#ifdef __linux__
@@ -473,21 +473,23 @@
int
rumpuser_cv_timedwait(struct rumpuser_cv *cv, struct rumpuser_mtx *mtx,
- struct timespec *ts)
+ int64_t sec, int64_t nsec)
{
+ struct timespec ts;
int rv;
+ /* LINTED */
+ ts.tv_sec = sec; ts.tv_nsec = nsec;
+
cv->nwaiters++;
mtxexit(mtx);
- KLOCK_WRAP(rv = pthread_cond_timedwait(&cv->pthcv, &mtx->pthmtx, ts));
+ KLOCK_WRAP(rv = pthread_cond_timedwait(&cv->pthcv, &mtx->pthmtx, &ts));
mtxenter(mtx);
cv->nwaiters--;
if (rv != 0 && rv != ETIMEDOUT)
abort();
- if (rv == ETIMEDOUT)
- rv = EWOULDBLOCK;
- return rv;
+ return rv == ETIMEDOUT;
}
void