Module Name: src Committed By: jmcneill Date: Tue Aug 23 14:37:50 UTC 2011
Modified Files: src/sys/arch/usermode/dev: clock.c src/sys/arch/usermode/include: thunk.h src/sys/arch/usermode/usermode: thunk.c Log Message: host and userkernel timespec might differ in size (because of time_t) so instead of thunk_clock_getres() filling in a timespec, use instead thunk_clock_getres_monotonic() that returns the resolution as a long To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/usermode/dev/clock.c cvs rdiff -u -r1.9 -r1.10 src/sys/arch/usermode/include/thunk.h cvs rdiff -u -r1.10 -r1.11 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.8 src/sys/arch/usermode/dev/clock.c:1.9 --- src/sys/arch/usermode/dev/clock.c:1.8 Sat Aug 13 12:06:22 2011 +++ src/sys/arch/usermode/dev/clock.c Tue Aug 23 14:37:50 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.8 2011/08/13 12:06:22 jmcneill Exp $ */ +/* $NetBSD: clock.c,v 1.9 2011/08/23 14:37:50 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.8 2011/08/13 12:06:22 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.9 2011/08/23 14:37:50 jmcneill Exp $"); #include <sys/param.h> #include <sys/proc.h> @@ -84,7 +84,7 @@ { clock_softc_t *sc = device_private(self); struct itimerval itimer; - struct timespec res; + long tcres; aprint_naive("\n"); aprint_normal("\n"); @@ -101,9 +101,10 @@ itimer.it_value = itimer.it_interval; thunk_setitimer(ITIMER_REAL, &itimer, NULL); - if (thunk_clock_getres(CLOCK_MONOTONIC, &res) == 0 && res.tv_nsec > 0) { + tcres = thunk_clock_getres_monotonic(); + if (tcres > 0) { clock_timecounter.tc_quality = 1000; - clock_timecounter.tc_frequency = 1000000000 / res.tv_nsec; + clock_timecounter.tc_frequency = 1000000000 / tcres; } tc_init(&clock_timecounter); } Index: src/sys/arch/usermode/include/thunk.h diff -u src/sys/arch/usermode/include/thunk.h:1.9 src/sys/arch/usermode/include/thunk.h:1.10 --- src/sys/arch/usermode/include/thunk.h:1.9 Mon Aug 22 15:30:16 2011 +++ src/sys/arch/usermode/include/thunk.h Tue Aug 23 14:37:50 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.h,v 1.9 2011/08/22 15:30:16 reinoud Exp $ */ +/* $NetBSD: thunk.h,v 1.10 2011/08/23 14:37:50 jmcneill Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill <jmcne...@invisible.ca> @@ -41,7 +41,7 @@ int thunk_setitimer(int, const struct itimerval *, struct itimerval *); int thunk_gettimeofday(struct timeval *, void *); int thunk_clock_gettime(clockid_t, struct timespec *); -int thunk_clock_getres(clockid_t, struct timespec *); +long thunk_clock_getres_monotonic(void); int thunk_usleep(useconds_t); void thunk_exit(int); Index: src/sys/arch/usermode/usermode/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.10 src/sys/arch/usermode/usermode/thunk.c:1.11 --- src/sys/arch/usermode/usermode/thunk.c:1.10 Mon Aug 22 21:45:38 2011 +++ src/sys/arch/usermode/usermode/thunk.c Tue Aug 23 14:37:50 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.10 2011/08/22 21:45:38 jmcneill Exp $ */ +/* $NetBSD: thunk.c,v 1.11 2011/08/23 14:37:50 jmcneill Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill <jmcne...@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: thunk.c,v 1.10 2011/08/22 21:45:38 jmcneill Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.11 2011/08/23 14:37:50 jmcneill Exp $"); #include <sys/types.h> #include <sys/ansi.h> @@ -65,10 +65,17 @@ return clock_gettime(clock_id, tp); } -int -thunk_clock_getres(clockid_t clock_id, struct timespec *res) +long +thunk_clock_getres_monotonic(void) { - return clock_getres(clock_id, res); + struct timespec res; + int error; + + error = clock_getres(CLOCK_MONOTONIC, &res); + if (error) + return -1; + + return res.tv_nsec; } int