Module Name:    src
Committed By:   jmcneill
Date:           Tue Dec 13 22:22:09 UTC 2011

Modified Files:
        src/sys/arch/usermode/dev: clock.c
        src/sys/arch/usermode/usermode: thunk.c

Log Message:
fix timecounter


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/usermode/dev/clock.c
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/usermode/usermode/thunk.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/arch/usermode/dev/clock.c
diff -u src/sys/arch/usermode/dev/clock.c:1.21 src/sys/arch/usermode/dev/clock.c:1.22
--- src/sys/arch/usermode/dev/clock.c:1.21	Fri Dec  9 17:23:33 2011
+++ src/sys/arch/usermode/dev/clock.c	Tue Dec 13 22:22:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: clock.c,v 1.21 2011/12/09 17:23:33 reinoud Exp $ */
+/* $NetBSD: clock.c,v 1.22 2011/12/13 22:22:08 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcne...@invisible.ca>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.21 2011/12/09 17:23:33 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.22 2011/12/13 22:22:08 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -63,7 +63,7 @@ static struct timecounter clock_timecoun
 	clock_getcounter,	/* get_timecount */
 	0,			/* no poll_pps */
 	~0u,			/* counter_mask */
-	0,			/* frequency */
+	1000000000ULL,		/* frequency */
 	"CLOCK_MONOTONIC",	/* name */
 	-100,			/* quality */
 	NULL,			/* prev */
@@ -117,7 +117,6 @@ clock_attach(device_t parent, device_t s
 	tcres = thunk_clock_getres_monotonic();
 	if (tcres > 0) {
 		clock_timecounter.tc_quality = 1000;
-		clock_timecounter.tc_frequency = 1000000000 / tcres;
 	}
 	tc_init(&clock_timecounter);
 }

Index: src/sys/arch/usermode/usermode/thunk.c
diff -u src/sys/arch/usermode/usermode/thunk.c:1.42 src/sys/arch/usermode/usermode/thunk.c:1.43
--- src/sys/arch/usermode/usermode/thunk.c:1.42	Mon Dec 12 16:39:16 2011
+++ src/sys/arch/usermode/usermode/thunk.c	Tue Dec 13 22:22:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.42 2011/12/12 16:39:16 jmcneill Exp $ */
+/* $NetBSD: thunk.c,v 1.43 2011/12/13 22:22:08 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcne...@invisible.ca>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.42 2011/12/12 16:39:16 jmcneill Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.43 2011/12/13 22:22:08 jmcneill Exp $");
 #endif
 
 #include <sys/types.h>
@@ -46,6 +46,7 @@ __RCSID("$NetBSD: thunk.c,v 1.42 2011/12
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
+#include <string.h>
 #include <termios.h>
 #include <time.h>
 #include <ucontext.h>
@@ -211,7 +212,7 @@ thunk_getcounter(void)
 		abort();
 	}
 
-	return (unsigned int)(ts.tv_sec * 1000000000ULL + ts.tv_nsec);
+	return (unsigned int)(ts.tv_nsec % 1000000000ULL);
 }
 
 long
@@ -224,7 +225,7 @@ thunk_clock_getres_monotonic(void)
 	if (error)
 		return -1;
 
-	return res.tv_nsec;
+	return (long)(res.tv_sec * 1000000000ULL + res.tv_nsec);
 }
 
 int

Reply via email to