Module Name:    src
Committed By:   christos
Date:           Sun Mar 29 19:21:20 UTC 2009

Modified Files:
        src/sys/compat/common: kern_time_50.c
        src/sys/compat/linux/common: linux_misc.c
        src/sys/compat/linux32/common: linux32_unistd.c
        src/sys/compat/netbsd32: netbsd32_compat_50.c netbsd32_select.c
        src/sys/compat/osf1: osf1_generic.c
        src/sys/kern: kern_event.c kern_time.c sys_select.c
        src/sys/netsmb: smb_trantcp.c
        src/sys/sys: poll.h select.h timevar.h

Log Message:
Move the internal poll/select related API's to use timespec instead
of timeval (rides the uvm bump).


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/compat/common/kern_time_50.c
cvs rdiff -u -r1.206 -r1.207 src/sys/compat/linux/common/linux_misc.c
cvs rdiff -u -r1.31 -r1.32 src/sys/compat/linux32/common/linux32_unistd.c
cvs rdiff -u -r1.3 -r1.4 src/sys/compat/netbsd32/netbsd32_compat_50.c
cvs rdiff -u -r1.16 -r1.17 src/sys/compat/netbsd32/netbsd32_select.c
cvs rdiff -u -r1.13 -r1.14 src/sys/compat/osf1/osf1_generic.c
cvs rdiff -u -r1.61 -r1.62 src/sys/kern/kern_event.c
cvs rdiff -u -r1.159 -r1.160 src/sys/kern/kern_time.c
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/sys_select.c
cvs rdiff -u -r1.41 -r1.42 src/sys/netsmb/smb_trantcp.c
cvs rdiff -u -r1.13 -r1.14 src/sys/sys/poll.h
cvs rdiff -u -r1.34 -r1.35 src/sys/sys/select.h
cvs rdiff -u -r1.24 -r1.25 src/sys/sys/timevar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/common/kern_time_50.c
diff -u src/sys/compat/common/kern_time_50.c:1.6 src/sys/compat/common/kern_time_50.c:1.7
--- src/sys/compat/common/kern_time_50.c:1.6	Thu Mar 26 18:22:14 2009
+++ src/sys/compat/common/kern_time_50.c	Sun Mar 29 15:21:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_time_50.c,v 1.6 2009/03/26 22:22:14 gmcgarry Exp $	*/
+/*	$NetBSD: kern_time_50.c,v 1.7 2009/03/29 19:21:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_time_50.c,v 1.6 2009/03/26 22:22:14 gmcgarry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time_50.c,v 1.7 2009/03/29 19:21:19 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ntp.h"
@@ -414,21 +414,21 @@
 		syscallarg(fd_set *)		ex;
 		syscallarg(struct timeval50 *)	tv;
 	} */
-	struct timeval atv, *tv = NULL;
+	struct timespec ats, *ts = NULL;
 	struct timeval50 atv50;
 	int error;
 
 	if (SCARG(uap, tv)) {
-		error = copyin(SCARG(uap, tv), (void *)&atv50,
-			sizeof(atv50));
+		error = copyin(SCARG(uap, tv), (void *)&atv50, sizeof(atv50));
 		if (error)
 			return error;
-		timeval50_to_timeval(&atv50, &atv);
-		tv = &atv;
+		ats.tv_sec = atv50.tv_sec;
+		ats.tv_nsec = atv50.tv_usec * 1000;
+		ts = &ats;
 	}
 
 	return selcommon(l, retval, SCARG(uap, nd), SCARG(uap, in),
-	    SCARG(uap, ou), SCARG(uap, ex), tv, NULL);
+	    SCARG(uap, ou), SCARG(uap, ex), ts, NULL);
 }
 
 int
@@ -444,8 +444,7 @@
 		syscallarg(sigset_t *)			mask;
 	} */
 	struct timespec50	ats50;
-	struct timespec	ats;
-	struct timeval	atv, *tv = NULL;
+	struct timespec	ats, *ts = NULL;
 	sigset_t	amask, *mask = NULL;
 	int		error;
 
@@ -454,9 +453,7 @@
 		if (error)
 			return error;
 		timespec50_to_timespec(&ats50, &ats);
-		atv.tv_sec = ats.tv_sec;
-		atv.tv_usec = ats.tv_nsec / 1000;
-		tv = &atv;
+		ts = &ats;
 	}
 	if (SCARG(uap, mask) != NULL) {
 		error = copyin(SCARG(uap, mask), &amask, sizeof(amask));
@@ -466,7 +463,7 @@
 	}
 
 	return selcommon(l, retval, SCARG(uap, nd), SCARG(uap, in),
-	    SCARG(uap, ou), SCARG(uap, ex), tv, mask);
+	    SCARG(uap, ou), SCARG(uap, ex), ts, mask);
 }
 int
 compat_50_sys_pollts(struct lwp *l, const struct compat_50_sys_pollts_args *uap,
@@ -478,8 +475,7 @@
 		syscallarg(const struct timespec50 *)	ts;
 		syscallarg(const sigset_t *)		mask;
 	} */
-	struct timespec	ats;
-	struct timeval	atv, *tv = NULL;
+	struct timespec	ats, *ts = NULL;
 	struct timespec50 ats50;
 	sigset_t	amask, *mask = NULL;
 	int		error;
@@ -489,9 +485,7 @@
 		if (error)
 			return error;
 		timespec50_to_timespec(&ats50, &ats);
-		atv.tv_sec = ats.tv_sec;
-		atv.tv_usec = ats.tv_nsec / 1000;
-		tv = &atv;
+		ts = &ats;
 	}
 	if (SCARG(uap, mask)) {
 		error = copyin(SCARG(uap, mask), &amask, sizeof(amask));
@@ -501,7 +495,7 @@
 	}
 
 	return pollcommon(l, retval, SCARG(uap, fds), SCARG(uap, nfds),
-		tv, mask);
+	    ts, mask);
 }
 
 int

Index: src/sys/compat/linux/common/linux_misc.c
diff -u src/sys/compat/linux/common/linux_misc.c:1.206 src/sys/compat/linux/common/linux_misc.c:1.207
--- src/sys/compat/linux/common/linux_misc.c:1.206	Sat Mar 14 17:04:18 2009
+++ src/sys/compat/linux/common/linux_misc.c	Sun Mar 29 15:21:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_misc.c,v 1.206 2009/03/14 21:04:18 dsl Exp $	*/
+/*	$NetBSD: linux_misc.c,v 1.207 2009/03/29 19:21:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.206 2009/03/14 21:04:18 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.207 2009/03/29 19:21:19 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -854,7 +854,7 @@
 int
 linux_select1(struct lwp *l, register_t *retval, int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct linux_timeval *timeout)
 {
-	struct timeval tv0, tv1, utv, *tv = NULL;
+	struct timespec ts0, ts1, uts, *ts = NULL;
 	struct linux_timeval ltv;
 	int error;
 
@@ -865,28 +865,28 @@
 	if (timeout) {
 		if ((error = copyin(timeout, &ltv, sizeof(ltv))))
 			return error;
-		utv.tv_sec = ltv.tv_sec;
-		utv.tv_usec = ltv.tv_usec;
-		if (itimerfix(&utv)) {
+		uts.tv_sec = ltv.tv_sec;
+		uts.tv_nsec = ltv.tv_usec * 1000;
+		if (itimespecfix(&uts)) {
 			/*
 			 * The timeval was invalid.  Convert it to something
 			 * valid that will act as it does under Linux.
 			 */
-			utv.tv_sec += utv.tv_usec / 1000000;
-			utv.tv_usec %= 1000000;
-			if (utv.tv_usec < 0) {
-				utv.tv_sec -= 1;
-				utv.tv_usec += 1000000;
+			uts.tv_sec += uts.tv_nsec / 1000000000;
+			uts.tv_nsec %= 1000000000;
+			if (uts.tv_nsec < 0) {
+				uts.tv_sec -= 1;
+				uts.tv_nsec += 1000000000;
 			}
-			if (utv.tv_sec < 0)
-				timerclear(&utv);
+			if (uts.tv_sec < 0)
+				timespecclear(&uts);
 		}
-		tv = &utv;
-		microtime(&tv0);
+		ts = &uts;
+		nanotime(&ts0);
 	}
 
 	error = selcommon(l, retval, nfds, readfds, writefds, exceptfds,
-	    tv, NULL);
+	    ts, NULL);
 
 	if (error) {
 		/*
@@ -906,15 +906,15 @@
 			 * before we started the call, and subtracting
 			 * that result from the user-supplied value.
 			 */
-			microtime(&tv1);
-			timersub(&tv1, &tv0, &tv1);
-			timersub(&utv, &tv1, &utv);
-			if (utv.tv_sec < 0)
-				timerclear(&utv);
+			nanotime(&ts1);
+			timespecsub(&ts1, &ts0, &ts1);
+			timespecsub(&uts, &ts1, &uts);
+			if (uts.tv_sec < 0)
+				timespecclear(&uts);
 		} else
-			timerclear(&utv);
-		ltv.tv_sec = utv.tv_sec;
-		ltv.tv_usec = utv.tv_usec;
+			timespecclear(&uts);
+		ltv.tv_sec = uts.tv_sec;
+		ltv.tv_usec = uts.tv_nsec / 1000;
 		if ((error = copyout(&ltv, timeout, sizeof(ltv))))
 			return error;
 	}

Index: src/sys/compat/linux32/common/linux32_unistd.c
diff -u src/sys/compat/linux32/common/linux32_unistd.c:1.31 src/sys/compat/linux32/common/linux32_unistd.c:1.32
--- src/sys/compat/linux32/common/linux32_unistd.c:1.31	Sun Mar 15 11:56:50 2009
+++ src/sys/compat/linux32/common/linux32_unistd.c	Sun Mar 29 15:21:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux32_unistd.c,v 1.31 2009/03/15 15:56:50 cegger Exp $ */
+/*	$NetBSD: linux32_unistd.c,v 1.32 2009/03/29 19:21:19 christos Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.31 2009/03/15 15:56:50 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.32 2009/03/29 19:21:19 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -147,11 +147,10 @@
 		fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
 		struct timeval *timeout)
 {   
-	struct timeval tv0, tv1, utv, *tv = NULL;
+	struct timespec ts0, ts1, uts, *ts = NULL;
 	struct netbsd32_timeval50 utv32;
 	int error;
 
-	timerclear(&utv); /* XXX GCC4 */
 
 	/*
 	 * Store current time for computation of the amount of
@@ -161,28 +160,30 @@
 		if ((error = copyin(timeout, &utv32, sizeof(utv32))))
 			return error;
 
-		netbsd32_to_timeval50(&utv32, &utv);
+		uts.tv_sec = utv32.tv_sec;
+		uts.tv_nsec = utv32.tv_usec * 1000;
 
-		if (itimerfix(&utv)) {
+		if (itimespecfix(&uts)) {
 			/*
 			 * The timeval was invalid.  Convert it to something
 			 * valid that will act as it does under Linux.
 			 */
-			utv.tv_sec += utv.tv_usec / 1000000;
-			utv.tv_usec %= 1000000;
-			if (utv.tv_usec < 0) {
-				utv.tv_sec -= 1;
-				utv.tv_usec += 1000000;
+			uts.tv_sec += uts.tv_nsec / 1000000000;
+			uts.tv_nsec %= 1000000000;
+			if (uts.tv_nsec < 0) {
+				uts.tv_sec -= 1;
+				uts.tv_nsec += 1000000000;
 			}
-			if (utv.tv_sec < 0)
-				timerclear(&utv);
+			if (uts.tv_sec < 0)
+				timespecclear(&uts);
 		}
-		microtime(&tv0);
-		tv = &utv;
-	}
+		nanotime(&ts0);
+		ts = &uts;
+	} else
+		timespecclear(&uts); /* XXX GCC4 */
 
 	error = selcommon(l, retval, nfds, 
-	    readfds, writefds, exceptfds, tv, NULL);
+	    readfds, writefds, exceptfds, ts, NULL);
 
 	if (error) {
 		/*
@@ -202,16 +203,17 @@
 			 * before we started the call, and subtracting
 			 * that result from the user-supplied value.
 			 */
-			microtime(&tv1);
-			timersub(&tv1, &tv0, &tv1);
-			timersub(&utv, &tv1, &utv);
-			if (utv.tv_sec < 0)
-				timerclear(&utv);
+			nanotime(&ts1);
+			timespecsub(&ts1, &ts0, &ts1);
+			timespecsub(&uts, &ts1, &uts);
+			if (uts.tv_sec < 0)
+				timespecclear(&uts);
 		} else {
-			timerclear(&utv);
+			timespecclear(&uts);
 		}
 		
-		netbsd32_from_timeval50(&utv, &utv32);
+		utv32.tv_sec = uts.tv_sec;
+		utv32.tv_usec = uts.tv_nsec / 1000;
 
 		if ((error = copyout(&utv32, timeout, sizeof(utv32))))
 			return error;

Index: src/sys/compat/netbsd32/netbsd32_compat_50.c
diff -u src/sys/compat/netbsd32/netbsd32_compat_50.c:1.3 src/sys/compat/netbsd32/netbsd32_compat_50.c:1.4
--- src/sys/compat/netbsd32/netbsd32_compat_50.c:1.3	Mon Jan 26 08:00:04 2009
+++ src/sys/compat/netbsd32/netbsd32_compat_50.c	Sun Mar 29 15:21:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_compat_50.c,v 1.3 2009/01/26 13:00:04 njoly Exp $	*/
+/*	$NetBSD: netbsd32_compat_50.c,v 1.4 2009/03/29 19:21:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.3 2009/01/26 13:00:04 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.4 2009/03/29 19:21:19 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_sysv.h"
@@ -129,18 +129,19 @@
 	} */
 	int error;
 	struct netbsd32_timeval50 tv32;
-	struct timeval atv, *tv = NULL;
+	struct timespec ats, *ts = NULL;
 
 	if (SCARG_P32(uap, tv)) {
 		error = copyin(SCARG_P32(uap, tv), &tv32, sizeof(tv32));
 		if (error != 0)
 			return error;
-		netbsd32_to_timeval50(&tv32, &atv);
-		tv = &atv;
+		ats.tv_sec = tv32.tv_sec;
+		ats.tv_nsec = tv32.tv_usec * 1000;
+		ts = &ats;
 	}
 
 	return selcommon(l, retval, SCARG(uap, nd), SCARG_P32(uap, in),
-	    SCARG_P32(uap, ou), SCARG_P32(uap, ex), tv, NULL);
+	    SCARG_P32(uap, ou), SCARG_P32(uap, ex), ts, NULL);
 	return 0;
 }
 
@@ -706,18 +707,15 @@
 	} */
 	int error;
 	struct netbsd32_timespec50 ts32;
-	struct timespec ts;
-	struct timeval atv, *tv = NULL;
+	struct timespec ats, *ts = NULL;
 	sigset_t amask, *mask = NULL;
 
 	if (SCARG_P32(uap, ts)) {
 		error = copyin(SCARG_P32(uap, ts), &ts32, sizeof(ts32));
 		if (error != 0)
 			return error;
-		netbsd32_to_timespec50(&ts32, &ts);
-		atv.tv_sec = ts.tv_sec;
-		atv.tv_usec = ts.tv_nsec / 1000;
-		tv = &atv;
+		netbsd32_to_timespec50(&ts32, &ats);
+		ts = &ats;
 	}
 	if (SCARG_P32(uap, mask)) {
 		error = copyin(SCARG_P32(uap, mask), &amask, sizeof(amask));
@@ -727,7 +725,7 @@
 	}
 
 	return selcommon(l, retval, SCARG(uap, nd), SCARG_P32(uap, in),
-	    SCARG_P32(uap, ou), SCARG_P32(uap, ex), tv, mask);
+	    SCARG_P32(uap, ou), SCARG_P32(uap, ex), ts, mask);
 	return 0;
 }
 
@@ -743,18 +741,15 @@
 	} */
 	int error;
 	struct netbsd32_timespec50 ts32;
-	struct timespec ts;
-	struct timeval atv, *tv = NULL;
+	struct timespec ats, *ts = NULL;
 	sigset_t amask, *mask = NULL;
 
 	if (SCARG_P32(uap, ts)) {
 		error = copyin(SCARG_P32(uap, ts), &ts32, sizeof(ts32));
 		if (error != 0)
 			return error;
-		netbsd32_to_timespec50(&ts32, &ts);
-		atv.tv_sec = ts.tv_sec;
-		atv.tv_usec = ts.tv_nsec / 1000;
-		tv = &atv;
+		netbsd32_to_timespec50(&ts32, &ats);
+		ts = &ats;
 	}
 	if (NETBSD32PTR64( SCARG(uap, mask))) {
 		error = copyin(SCARG_P32(uap, mask), &amask, sizeof(amask));
@@ -764,7 +759,7 @@
 	}
 
 	return pollcommon(l, retval, SCARG_P32(uap, fds),
-	    SCARG(uap, nfds), tv, mask);
+	    SCARG(uap, nfds), ts, mask);
 }
 
 int

Index: src/sys/compat/netbsd32/netbsd32_select.c
diff -u src/sys/compat/netbsd32/netbsd32_select.c:1.16 src/sys/compat/netbsd32/netbsd32_select.c:1.17
--- src/sys/compat/netbsd32/netbsd32_select.c:1.16	Sat Jan 10 21:45:49 2009
+++ src/sys/compat/netbsd32/netbsd32_select.c	Sun Mar 29 15:21:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_select.c,v 1.16 2009/01/11 02:45:49 christos Exp $	*/
+/*	$NetBSD: netbsd32_select.c,v 1.17 2009/03/29 19:21:19 christos Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_select.c,v 1.16 2009/01/11 02:45:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_select.c,v 1.17 2009/03/29 19:21:19 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -62,18 +62,19 @@
 	} */
 	int error;
 	struct netbsd32_timeval tv32;
-	struct timeval atv, *tv = NULL;
+	struct timespec ats, *ts = NULL;
 
 	if (SCARG_P32(uap, tv)) {
 		error = copyin(SCARG_P32(uap, tv), &tv32, sizeof(tv32));
 		if (error != 0)
 			return error;
-		netbsd32_to_timeval(&tv32, &atv);
-		tv = &atv;
+		ats.tv_sec = tv32.tv_sec;
+		ats.tv_nsec = tv32.tv_usec * 1000;
+		ts = &ats;
 	}
 
 	return selcommon(l, retval, SCARG(uap, nd), SCARG_P32(uap, in),
-	    SCARG_P32(uap, ou), SCARG_P32(uap, ex), tv, NULL);
+	    SCARG_P32(uap, ou), SCARG_P32(uap, ex), ts, NULL);
 }
 
 int
@@ -89,18 +90,15 @@
 	} */
 	int error;
 	struct netbsd32_timespec ts32;
-	struct timespec ts;
-	struct timeval atv, *tv = NULL;
+	struct timespec ats, *ts = NULL;
 	sigset_t amask, *mask = NULL;
 
 	if (SCARG_P32(uap, ts)) {
 		error = copyin(SCARG_P32(uap, ts), &ts32, sizeof(ts32));
 		if (error != 0)
 			return error;
-		netbsd32_to_timespec(&ts32, &ts);
-		atv.tv_sec = ts.tv_sec;
-		atv.tv_usec = ts.tv_nsec / 1000;
-		tv = &atv;
+		netbsd32_to_timespec(&ts32, &ats);
+		ts = &ats;
 	}
 	if (SCARG_P32(uap, mask)) {
 		error = copyin(SCARG_P32(uap, mask), &amask, sizeof(amask));
@@ -110,7 +108,7 @@
 	}
 
 	return selcommon(l, retval, SCARG(uap, nd), SCARG_P32(uap, in),
-	    SCARG_P32(uap, ou), SCARG_P32(uap, ex), tv, mask);
+	    SCARG_P32(uap, ou), SCARG_P32(uap, ex), ts, mask);
 }
 
 int
@@ -124,18 +122,15 @@
 	} */
 	int error;
 	struct netbsd32_timespec ts32;
-	struct timespec ts;
-	struct timeval atv, *tv = NULL;
+	struct timespec ats, *ts = NULL;
 	sigset_t amask, *mask = NULL;
 
 	if (SCARG_P32(uap, ts)) {
 		error = copyin(SCARG_P32(uap, ts), &ts32, sizeof(ts32));
 		if (error != 0)
 			return error;
-		netbsd32_to_timespec(&ts32, &ts);
-		atv.tv_sec = ts.tv_sec;
-		atv.tv_usec = ts.tv_nsec / 1000;
-		tv = &atv;
+		netbsd32_to_timespec(&ts32, &ats);
+		ts = &ats;
 	}
 	if (NETBSD32PTR64( SCARG(uap, mask))) {
 		error = copyin(SCARG_P32(uap, mask), &amask, sizeof(amask));
@@ -145,5 +140,5 @@
 	}
 
 	return pollcommon(l, retval, SCARG_P32(uap, fds),
-	    SCARG(uap, nfds), tv, mask);
+	    SCARG(uap, nfds), ts, mask);
 }

Index: src/sys/compat/osf1/osf1_generic.c
diff -u src/sys/compat/osf1/osf1_generic.c:1.13 src/sys/compat/osf1/osf1_generic.c:1.14
--- src/sys/compat/osf1/osf1_generic.c:1.13	Thu Dec 20 18:03:02 2007
+++ src/sys/compat/osf1/osf1_generic.c	Sun Mar 29 15:21:19 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: osf1_generic.c,v 1.13 2007/12/20 23:03:02 dsl Exp $ */
+/* $NetBSD: osf1_generic.c,v 1.14 2009/03/29 19:21:19 christos Exp $ */
 
 /*
  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: osf1_generic.c,v 1.13 2007/12/20 23:03:02 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: osf1_generic.c,v 1.14 2009/03/29 19:21:19 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -162,23 +162,20 @@
 osf1_sys_select(struct lwp *l, const struct osf1_sys_select_args *uap, register_t *retval)
 {
 	struct osf1_timeval otv;
-	struct timeval tv, *tvp;
+	struct timespec ats, *ts = NULL;
 	int error;
 
-	if (SCARG(uap, tv) == NULL)
-		tvp = NULL;
-	else {
+	if (SCARG(uap, tv)) {
 		/* get the OSF/1 timeval argument */
 		error = copyin(SCARG(uap, tv), &otv, sizeof otv);
 		if (error != 0)
 			return error;
 
-		/* copy to the NetBSD timeval */
-		tv.tv_sec = otv.tv_sec;
-		tv.tv_usec = otv.tv_usec;
-		tvp = &tv;
+		ats.tv_sec = otv.tv_sec;
+		ats.tv_nsec = otv.tv_usec * 1000;
+		ts = &atv;
 	}
 
 	return selcommon(l, retval, SCARG(uap, nd), SCARG(uap, in),
-	    SCARG(uap, ou), SCARG(uap, ex), tvp, NULL);
+	    SCARG(uap, ou), SCARG(uap, ex), tsp, NULL);
 }

Index: src/sys/kern/kern_event.c
diff -u src/sys/kern/kern_event.c:1.61 src/sys/kern/kern_event.c:1.62
--- src/sys/kern/kern_event.c:1.61	Sat Jan 10 21:45:52 2009
+++ src/sys/kern/kern_event.c	Sun Mar 29 15:21:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_event.c,v 1.61 2009/01/11 02:45:52 christos Exp $	*/
+/*	$NetBSD: kern_event.c,v 1.62 2009/03/29 19:21:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.61 2009/01/11 02:45:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.62 2009/03/29 19:21:19 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1064,7 +1064,7 @@
 {
 	struct kqueue	*kq;
 	struct kevent	*kevp;
-	struct timeval	atv, sleeptv;
+	struct timespec	ats, sleepts;
 	struct knote	*kn, *marker;
 	size_t		count, nkev, nevents;
 	int		timeout, error, rv;
@@ -1080,12 +1080,11 @@
 	}
 
 	if (tsp) {				/* timeout supplied */
-		TIMESPEC_TO_TIMEVAL(&atv, tsp);
-		if (inittimeleft(&atv, &sleeptv) == -1) {
+		if (inittimeleft(&ats, &sleepts) == -1) {
 			*retval = maxevents;
 			return EINVAL;
 		}
-		timeout = tvtohz(&atv);
+		timeout = tstohz(&ats);
 		if (timeout <= 0)
 			timeout = -1;           /* do poll */
 	} else {
@@ -1104,7 +1103,7 @@
 			    &kq->kq_lock, timeout);
 			if (error == 0) {
 				 if (tsp == NULL || (timeout =
-				     gettimeleft(&atv, &sleeptv)) > 0)
+				     gettimeleft(&ats, &sleepts)) > 0)
 					goto retry;
 			} else {
 				/* don't restart after signals... */
@@ -1125,8 +1124,8 @@
 					/* it's our marker, stop */
 					TAILQ_REMOVE(&kq->kq_head, kn, kn_tqe);
 					if (count < maxevents || (tsp != NULL &&
-					    (timeout = gettimeleft(&atv,
-					    &sleeptv)) <= 0))
+					    (timeout = gettimeleft(&ats,
+					    &sleepts)) <= 0))
 						goto done;
 					goto retry;
 				}

Index: src/sys/kern/kern_time.c
diff -u src/sys/kern/kern_time.c:1.159 src/sys/kern/kern_time.c:1.160
--- src/sys/kern/kern_time.c:1.159	Sat Jan 31 10:53:36 2009
+++ src/sys/kern/kern_time.c	Sun Mar 29 15:21:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_time.c,v 1.159 2009/01/31 15:53:36 yamt Exp $	*/
+/*	$NetBSD: kern_time.c,v 1.160 2009/03/29 19:21:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.159 2009/01/31 15:53:36 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.160 2009/03/29 19:21:19 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/resourcevar.h>
@@ -297,8 +297,8 @@
 	struct timespec rmtstart;
 	int error, timo;
 
-	if (itimespecfix(rqt))
-		return (EINVAL);
+	if ((error = itimespecfix(rqt)) != 0)
+		return error;
 
 	timo = tstohz(rqt);
 	/*
@@ -769,14 +769,16 @@
 	struct itimerspec val, oval;
 	struct ptimers *pts;
 	struct ptimer *pt;
+	int error;
 
 	pts = p->p_timers;
 
 	if (pts == NULL || timerid < 2 || timerid >= TIMER_MAX)
 		return EINVAL;
 	val = *value;
-	if (itimespecfix(&val.it_value) || itimespecfix(&val.it_interval))
-		return EINVAL;
+	if ((error = itimespecfix(&val.it_value)) != 0 ||
+	    (error = itimespecfix(&val.it_interval)) != 0)
+		return error;
 
 	mutex_spin_enter(&timer_lock);
 	if ((pt = pts->pts_timers[timerid]) == NULL) {

Index: src/sys/kern/sys_select.c
diff -u src/sys/kern/sys_select.c:1.13 src/sys/kern/sys_select.c:1.14
--- src/sys/kern/sys_select.c:1.13	Sat Mar 21 09:11:14 2009
+++ src/sys/kern/sys_select.c	Sun Mar 29 15:21:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_select.c,v 1.13 2009/03/21 13:11:14 ad Exp $	*/
+/*	$NetBSD: sys_select.c,v 1.14 2009/03/29 19:21:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.13 2009/03/21 13:11:14 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.14 2009/03/29 19:21:19 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -135,8 +135,7 @@
 		syscallarg(const struct timespec *)	ts;
 		syscallarg(sigset_t *)			mask;
 	} */
-	struct timespec	ats;
-	struct timeval	atv, *tv = NULL;
+	struct timespec	ats, *ts = NULL;
 	sigset_t	amask, *mask = NULL;
 	int		error;
 
@@ -144,9 +143,7 @@
 		error = copyin(SCARG(uap, ts), &ats, sizeof(ats));
 		if (error)
 			return error;
-		atv.tv_sec = ats.tv_sec;
-		atv.tv_usec = ats.tv_nsec / 1000;
-		tv = &atv;
+		ts = &ats;
 	}
 	if (SCARG(uap, mask) != NULL) {
 		error = copyin(SCARG(uap, mask), &amask, sizeof(amask));
@@ -156,34 +153,34 @@
 	}
 
 	return selcommon(l, retval, SCARG(uap, nd), SCARG(uap, in),
-	    SCARG(uap, ou), SCARG(uap, ex), tv, mask);
+	    SCARG(uap, ou), SCARG(uap, ex), ts, mask);
 }
 
 int
-inittimeleft(struct timeval *tv, struct timeval *sleeptv)
+inittimeleft(struct timespec *ts, struct timespec *sleepts)
 {
-	if (itimerfix(tv))
+	if (itimespecfix(ts))
 		return -1;
-	getmicrouptime(sleeptv);
+	getnanouptime(sleepts);
 	return 0;
 }
 
 int
-gettimeleft(struct timeval *tv, struct timeval *sleeptv)
+gettimeleft(struct timespec *ts, struct timespec *sleepts)
 {
 	/*
 	 * We have to recalculate the timeout on every retry.
 	 */
-	struct timeval slepttv;
+	struct timespec sleptts;
 	/*
-	 * reduce tv by elapsed time
+	 * reduce ts by elapsed time
 	 * based on monotonic time scale
 	 */
-	getmicrouptime(&slepttv);
-	timeradd(tv, sleeptv, tv);
-	timersub(tv, &slepttv, tv);
-	*sleeptv = slepttv;
-	return tvtohz(tv);
+	getnanouptime(&sleptts);
+	timespecadd(ts, sleepts, ts);
+	timespecsub(ts, &sleptts, ts);
+	*sleepts = sleptts;
+	return tstohz(ts);
 }
 
 int
@@ -197,24 +194,25 @@
 		syscallarg(fd_set *)		ex;
 		syscallarg(struct timeval *)	tv;
 	} */
-	struct timeval atv, *tv = NULL;
+	struct timeval atv;
+	struct timespec ats, *ts = NULL;
 	int error;
 
 	if (SCARG(uap, tv)) {
-		error = copyin(SCARG(uap, tv), (void *)&atv,
-			sizeof(atv));
+		error = copyin(SCARG(uap, tv), (void *)&atv, sizeof(atv));
 		if (error)
 			return error;
-		tv = &atv;
+		TIMEVAL_TO_TIMESPEC(&atv, &ats);
+		ts = &ats;
 	}
 
 	return selcommon(l, retval, SCARG(uap, nd), SCARG(uap, in),
-	    SCARG(uap, ou), SCARG(uap, ex), tv, NULL);
+	    SCARG(uap, ou), SCARG(uap, ex), ts, NULL);
 }
 
 int
 selcommon(lwp_t *l, register_t *retval, int nd, fd_set *u_in,
-	  fd_set *u_ou, fd_set *u_ex, struct timeval *tv, sigset_t *mask)
+	  fd_set *u_ou, fd_set *u_ex, struct timespec *ts, sigset_t *mask)
 {
 	char		smallbits[howmany(FD_SETSIZE, NFDBITS) *
 			    sizeof(fd_mask) * 6];
@@ -223,7 +221,7 @@
 	int		ncoll, error, timo;
 	size_t		ni;
 	sigset_t	oldmask;
-	struct timeval  sleeptv;
+	struct timespec sleepts;
 	selcpu_t	*sc;
 	kmutex_t	*lock;
 
@@ -255,7 +253,7 @@
 #undef	getbits
 
 	timo = 0;
-	if (tv && inittimeleft(tv, &sleeptv) == -1) {
+	if (ts && inittimeleft(ts, &sleepts) == -1) {
 		error = EINVAL;
 		goto done;
 	}
@@ -290,7 +288,7 @@
 
 		if (error || *retval)
 			break;
-		if (tv && (timo = gettimeleft(tv, &sleeptv)) <= 0)
+		if (ts && (timo = gettimeleft(ts, &sleepts)) <= 0)
 			break;
 		mutex_spin_enter(lock);
 		if (l->l_selflag != SEL_SCANNING || sc->sc_ncoll != ncoll) {
@@ -374,16 +372,16 @@
 		syscallarg(u_int)		nfds;
 		syscallarg(int)			timeout;
 	} */
-	struct timeval	atv, *tv = NULL;
+	struct timespec	ats, *ts = NULL;
 
 	if (SCARG(uap, timeout) != INFTIM) {
-		atv.tv_sec = SCARG(uap, timeout) / 1000;
-		atv.tv_usec = (SCARG(uap, timeout) % 1000) * 1000;
-		tv = &atv;
+		ats.tv_sec = SCARG(uap, timeout) / 1000;
+		ats.tv_nsec = (SCARG(uap, timeout) % 1000) * 1000000;
+		ts = &ats;
 	}
 
 	return pollcommon(l, retval, SCARG(uap, fds), SCARG(uap, nfds),
-		tv, NULL);
+		ts, NULL);
 }
 
 /*
@@ -399,8 +397,7 @@
 		syscallarg(const struct timespec *)	ts;
 		syscallarg(const sigset_t *)		mask;
 	} */
-	struct timespec	ats;
-	struct timeval	atv, *tv = NULL;
+	struct timespec	ats, *ts = NULL;
 	sigset_t	amask, *mask = NULL;
 	int		error;
 
@@ -408,9 +405,7 @@
 		error = copyin(SCARG(uap, ts), &ats, sizeof(ats));
 		if (error)
 			return error;
-		atv.tv_sec = ats.tv_sec;
-		atv.tv_usec = ats.tv_nsec / 1000;
-		tv = &atv;
+		ts = &ats;
 	}
 	if (SCARG(uap, mask)) {
 		error = copyin(SCARG(uap, mask), &amask, sizeof(amask));
@@ -420,13 +415,12 @@
 	}
 
 	return pollcommon(l, retval, SCARG(uap, fds), SCARG(uap, nfds),
-		tv, mask);
+	    ts, mask);
 }
 
 int
-pollcommon(lwp_t *l, register_t *retval,
-	struct pollfd *u_fds, u_int nfds,
-	struct timeval *tv, sigset_t *mask)
+pollcommon(lwp_t *l, register_t *retval, struct pollfd *u_fds, u_int nfds,
+    struct timespec *ts, sigset_t *mask)
 {
 	struct pollfd	smallfds[32];
 	struct pollfd	*fds;
@@ -434,7 +428,7 @@
 	sigset_t	oldmask;
 	int		ncoll, error, timo;
 	size_t		ni;
-	struct timeval	sleeptv;
+	struct timespec	sleepts;
 	selcpu_t	*sc;
 	kmutex_t	*lock;
 
@@ -455,7 +449,7 @@
 		goto done;
 
 	timo = 0;
-	if (tv && inittimeleft(tv, &sleeptv) == -1) {
+	if (ts && inittimeleft(ts, &sleepts) == -1) {
 		error = EINVAL;
 		goto done;
 	}
@@ -489,7 +483,7 @@
 
 		if (error || *retval)
 			break;
-		if (tv && (timo = gettimeleft(tv, &sleeptv)) <= 0)
+		if (ts && (timo = gettimeleft(ts, &sleepts)) <= 0)
 			break;
 		mutex_spin_enter(lock);
 		if (l->l_selflag != SEL_SCANNING || sc->sc_ncoll != ncoll) {
@@ -791,18 +785,18 @@
 }
 
 int
-pollsock(struct socket *so, const struct timeval *tvp, int events)
+pollsock(struct socket *so, const struct timespec *tsp, int events)
 {
 	int		ncoll, error, timo;
-	struct timeval	sleeptv, tv;
+	struct timespec	sleepts, ts;
 	selcpu_t	*sc;
 	lwp_t		*l;
 	kmutex_t	*lock;
 
 	timo = 0;
-	if (tvp != NULL) {
-		tv = *tvp;
-		if (inittimeleft(&tv, &sleeptv) == -1)
+	if (tsp != NULL) {
+		ts = *tsp;
+		if (inittimeleft(&ts, &sleepts) == -1)
 			return EINVAL;
 	}
 
@@ -825,7 +819,7 @@
 		l->l_selflag = SEL_SCANNING;
 		if (sopoll(so, events) != 0)
 			break;
-		if (tvp && (timo = gettimeleft(&tv, &sleeptv)) <= 0)
+		if (tsp && (timo = gettimeleft(&ts, &sleepts)) <= 0)
 			break;
 		mutex_spin_enter(lock);
 		if (l->l_selflag != SEL_SCANNING || sc->sc_ncoll != ncoll) {

Index: src/sys/netsmb/smb_trantcp.c
diff -u src/sys/netsmb/smb_trantcp.c:1.41 src/sys/netsmb/smb_trantcp.c:1.42
--- src/sys/netsmb/smb_trantcp.c:1.41	Wed Mar 18 12:00:24 2009
+++ src/sys/netsmb/smb_trantcp.c	Sun Mar 29 15:21:20 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: smb_trantcp.c,v 1.41 2009/03/18 16:00:24 cegger Exp $	*/
+/*	$NetBSD: smb_trantcp.c,v 1.42 2009/03/29 19:21:20 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smb_trantcp.c,v 1.41 2009/03/18 16:00:24 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smb_trantcp.c,v 1.42 2009/03/29 19:21:20 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -96,7 +96,7 @@
 
 static int nb_tcpsndbuf = NB_SNDQ;
 static int nb_tcprcvbuf = NB_RCVQ;
-static const struct timeval nb_timo = { 15, 0 };	/* XXX sysctl? */
+static const struct timespec nb_timo = { 15, 0 };	/* XXX sysctl? */
 
 #define nb_sosend(so,m,flags,l) (*(so)->so_send)(so, NULL, (struct uio *)0, \
 					m, (struct mbuf *)0, flags, l)
@@ -113,11 +113,11 @@
 }
 
 static int
-nbssn_rselect(struct nbpcb *nbp, const struct timeval *tv, int events,
+nbssn_rselect(struct nbpcb *nbp, const struct timespec *ts, int events,
 	struct lwp *l)
 {
 
-	return pollsock(nbp->nbp_tso, tv, events);
+	return pollsock(nbp->nbp_tso, ts, events);
 }
 
 static int
@@ -636,6 +636,7 @@
 static int
 smb_nbst_getparam(struct smb_vc *vcp, int param, void *data)
 {
+	struct timeval *tvp;
 	switch (param) {
 	case SMBTP_SNDSZ:
 		*(int*)data = nb_tcpsndbuf;
@@ -644,7 +645,9 @@
 		*(int*)data = nb_tcprcvbuf;
 		break;
 	case SMBTP_TIMEOUT:
-		*(struct timeval*)data = nb_timo;
+		tvp = (struct timeval *)data;
+		tvp->tv_sec = nb_timo.tv_sec;
+		tvp->tv_usec = nb_timo.tv_nsec / 1000;
 		break;
 	default:
 		return EINVAL;

Index: src/sys/sys/poll.h
diff -u src/sys/sys/poll.h:1.13 src/sys/sys/poll.h:1.14
--- src/sys/sys/poll.h:1.13	Sat Jan 10 21:45:55 2009
+++ src/sys/sys/poll.h	Sun Mar 29 15:21:20 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: poll.h,v 1.13 2009/01/11 02:45:55 christos Exp $	*/
+/*	$NetBSD: poll.h,v 1.14 2009/03/29 19:21:20 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -71,10 +71,10 @@
 #include <sys/signal.h>		/* for sigset_t */
 
 struct lwp;
-struct timeval;
+struct timespec;
 
 int	pollcommon(struct lwp *, register_t *, struct pollfd *, u_int,
-	    struct timeval *, sigset_t *);
+    struct timespec *, sigset_t *);
 #else
 #include <sys/cdefs.h>
 

Index: src/sys/sys/select.h
diff -u src/sys/sys/select.h:1.34 src/sys/sys/select.h:1.35
--- src/sys/sys/select.h:1.34	Sat Jan 10 21:45:55 2009
+++ src/sys/sys/select.h	Sun Mar 29 15:21:20 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: select.h,v 1.34 2009/01/11 02:45:55 christos Exp $	*/
+/*	$NetBSD: select.h,v 1.35 2009/03/29 19:21:20 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -44,18 +44,18 @@
 
 struct lwp;
 struct proc;
-struct timeval;
+struct timespec;
 struct cpu_info;
 struct socket;
 
 int	selcommon(struct lwp *, register_t *, int, fd_set *, fd_set *,
-	    fd_set *, struct timeval *, sigset_t *);
+    fd_set *, struct timespec *, sigset_t *);
 void	selrecord(struct lwp *selector, struct selinfo *);
 void	selnotify(struct selinfo *, int, long);
 void	selsysinit(struct cpu_info *);
 void	selinit(struct selinfo *);
 void	seldestroy(struct selinfo *);
-int	pollsock(struct socket *, const struct timeval *, int);
+int	pollsock(struct socket *, const struct timespec *, int);
 
 #else /* _KERNEL */
 

Index: src/sys/sys/timevar.h
diff -u src/sys/sys/timevar.h:1.24 src/sys/sys/timevar.h:1.25
--- src/sys/sys/timevar.h:1.24	Sat Jan 10 21:45:56 2009
+++ src/sys/sys/timevar.h	Sun Mar 29 15:21:20 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: timevar.h,v 1.24 2009/01/11 02:45:56 christos Exp $	*/
+/*	$NetBSD: timevar.h,v 1.25 2009/03/29 19:21:20 christos Exp $	*/
 
 /*
  *  Copyright (c) 2005, 2008 The NetBSD Foundation.
@@ -173,8 +173,8 @@
 void	timer_tick(struct lwp *, bool);
 int	tstohz(const struct timespec *);
 int	tvtohz(const struct timeval *);
-int	inittimeleft(struct timeval *, struct timeval *);
-int	gettimeleft(struct timeval *, struct timeval *);
+int	inittimeleft(struct timespec *, struct timespec *);
+int	gettimeleft(struct timespec *, struct timespec *);
 void	timerupcall(struct lwp *);
 void	time_init(void);
 void	time_init2(void);

Reply via email to