@@ -1,4 +1,4 @@
-/* $NetBSD: kern_time.c,v 1.170 2011/10/27 16:12:52 christos Exp $ */
+/* $NetBSD: kern_time.c,v 1.171 2011/12/18 22:30:25 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.170 2011/10/27 16:12:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.171 2011/12/18 22:30:25 christos Exp $");
#include <sys/param.h>
#include <sys/resourcevar.h>
@@ -674,7 +674,10 @@
* Don't need to check tshzto() return value, here.
* callout_reset() does it for us.
*/
- callout_reset(&pt->pt_ch, tshzto(&pt->pt_time.it_value),
+ callout_reset(&pt->pt_ch,
+ pt->pt_type == CLOCK_MONOTONIC ?
+ tshztoup(&pt->pt_time.it_value) :
+ tshzto(&pt->pt_time.it_value),
realtimerexpire, pt);
}
} else {
@@ -1004,7 +1007,11 @@
return;
}
- getnanotime(&now);
+ if (pt->pt_type == CLOCK_MONOTONIC) {
+ getnanouptime(&now);
+ } else {
+ getnanotime(&now);
+ }
backwards = (timespeccmp(&pt->pt_time.it_value, &now, >));
timespecadd(&pt->pt_time.it_value, &pt->pt_time.it_interval, &next);
/* Handle the easy case of non-overflown timers first. */
@@ -1031,7 +1038,8 @@
* Don't need to check tshzto() return value, here.
* callout_reset() does it for us.
*/
- callout_reset(&pt->pt_ch, tshzto(&pt->pt_time.it_value),
+ callout_reset(&pt->pt_ch, pt->pt_type == CLOCK_MONOTONIC ?
+ tshztoup(&pt->pt_time.it_value) : tshzto(&pt->pt_time.it_value),
realtimerexpire, pt);
mutex_spin_exit(&timer_lock);
}
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_time.c,v 1.8 2011/01/26 19:15:13 drochner Exp $ */
+/* $NetBSD: subr_time.c,v 1.9 2011/12/18 22:30:25 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_time.c,v 1.8 2011/01/26 19:15:13 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_time.c,v 1.9 2011/12/18 22:30:25 christos Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -129,6 +129,18 @@
timespecsub(&ts, &now, &ts);
return tstohz(&ts);
}
+
+int
+tshztoup(const struct timespec *tsp)
+{
+ struct timespec now, ts;
+
+ ts = *tsp; /* Don't modify original tsp. */
+ getnanouptime(&now);
+ timespecsub(&ts, &now, &ts);
+ return tstohz(&ts);
+}
+
/*
* Compute number of ticks in the specified amount of time.
*/
@@ -1,4 +1,4 @@
-/* $NetBSD: timevar.h,v 1.29 2010/04/08 11:51:13 njoly Exp $ */
+/* $NetBSD: timevar.h,v 1.30 2011/12/18 22:30:25 christos Exp $ */
/*
* Copyright (c) 2005, 2008 The NetBSD Foundation.
@@ -156,6 +156,7 @@
int dotimer_settime(int, struct itimerspec *, struct itimerspec *, int,
struct proc *);
int tshzto(const struct timespec *);
+int tshztoup(const struct timespec *);
int tvhzto(const struct timeval *);
void inittimecounter(void);
int itimerfix(struct timeval *);