fix timecounter

This commit is contained in:
jmcneill 2011-12-13 22:22:08 +00:00
parent ee093755eb
commit 5812e0a0a0
2 changed files with 8 additions and 8 deletions

View File

@ -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 <jmcneill@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_timecounter = {
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 self, void *opaque)
tcres = thunk_clock_getres_monotonic();
if (tcres > 0) {
clock_timecounter.tc_quality = 1000;
clock_timecounter.tc_frequency = 1000000000 / tcres;
}
tc_init(&clock_timecounter);
}

View File

@ -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 <jmcneill@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/12 16:39:16 jmcneill Exp $");
#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