summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorjmcneill <jmcneill@NetBSD.org>2011-08-23 16:09:27 +0000
committerjmcneill <jmcneill@NetBSD.org>2011-08-23 16:09:27 +0000
commit366d752ca1b2bb0b2d64967d688ca52c99864477 (patch)
treedbf8bcd0ef986ca8e08e2ab634cff8ab1842f251 /sys
parentc04f72b7b6e632b81229611a346cf934bffcab23 (diff)
more host vs. userkernel time_t fixes
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/usermode/dev/clock.c25
-rw-r--r--sys/arch/usermode/include/thunk.h11
-rw-r--r--sys/arch/usermode/usermode/thunk.c33
3 files changed, 50 insertions, 19 deletions
diff --git a/sys/arch/usermode/dev/clock.c b/sys/arch/usermode/dev/clock.c
index ee6f6b6bf27..a0565822657 100644
--- a/sys/arch/usermode/dev/clock.c
+++ b/sys/arch/usermode/dev/clock.c
@@ -1,4 +1,4 @@
-/* $NetBSD: clock.c,v 1.9 2011/08/23 14:37:50 jmcneill Exp $ */
+/* $NetBSD: clock.c,v 1.10 2011/08/23 16:09:27 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.9 2011/08/23 14:37:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.10 2011/08/23 16:09:27 jmcneill Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -45,7 +45,7 @@ static int clock_match(device_t, cfdata_t, void *);
static void clock_attach(device_t, device_t, void *);
static void clock_intr(int);
-static u_int clock_getcounter(struct timecounter *);
+static unsigned int clock_getcounter(struct timecounter *);
static int clock_todr_gettime(struct todr_chip_handle *, struct timeval *);
@@ -122,17 +122,24 @@ clock_intr(int notused)
curcpu()->ci_idepth--;
}
-static u_int
+static unsigned int
clock_getcounter(struct timecounter *tc)
{
- struct timespec ts;
-
- thunk_clock_gettime(CLOCK_MONOTONIC, &ts);
- return ts.tv_nsec;
+ return thunk_getcounter();
}
static int
clock_todr_gettime(struct todr_chip_handle *tch, struct timeval *tv)
{
- return thunk_gettimeofday(tv, NULL);
+ struct thunk_timeval ttv;
+ int error;
+
+ error = thunk_gettimeofday(&ttv, NULL);
+ if (error)
+ return error;
+
+ tv->tv_sec = ttv.tv_sec;
+ tv->tv_usec = ttv.tv_usec;
+
+ return 0;
}
diff --git a/sys/arch/usermode/include/thunk.h b/sys/arch/usermode/include/thunk.h
index 63f960522fd..a9df1dad477 100644
--- a/sys/arch/usermode/include/thunk.h
+++ b/sys/arch/usermode/include/thunk.h
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.10 2011/08/23 14:37:50 jmcneill Exp $ */
+/* $NetBSD: thunk.h,v 1.11 2011/08/23 16:09:27 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
@@ -38,9 +38,14 @@
#include <sys/aio.h>
#include <sys/mman.h>
+struct thunk_timeval {
+ int64_t tv_sec;
+ int32_t tv_usec;
+};
+
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_gettimeofday(struct thunk_timeval *, void *);
+unsigned int thunk_getcounter(void);
long thunk_clock_getres_monotonic(void);
int thunk_usleep(useconds_t);
diff --git a/sys/arch/usermode/usermode/thunk.c b/sys/arch/usermode/usermode/thunk.c
index 5626654d942..a94bc4fdfed 100644
--- a/sys/arch/usermode/usermode/thunk.c
+++ b/sys/arch/usermode/usermode/thunk.c
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.11 2011/08/23 14:37:50 jmcneill Exp $ */
+/* $NetBSD: thunk.c,v 1.12 2011/08/23 16:09:27 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: thunk.c,v 1.11 2011/08/23 14:37:50 jmcneill Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.12 2011/08/23 16:09:27 jmcneill Exp $");
#include <sys/types.h>
#include <sys/ansi.h>
@@ -54,15 +54,34 @@ thunk_setitimer(int which, const struct itimerval *value,
}
int
-thunk_gettimeofday(struct timeval *tp, void *tzp)
+thunk_gettimeofday(struct thunk_timeval *tp, void *tzp)
{
- return gettimeofday(tp, tzp);
+ struct timeval tv;
+ int error;
+
+ error = gettimeofday(&tv, tzp);
+ if (error)
+ return error;
+
+ tp->tv_sec = tv.tv_sec;
+ tp->tv_usec = tv.tv_usec;
+
+ return 0;
}
-int
-thunk_clock_gettime(clockid_t clock_id, struct timespec *tp)
+unsigned int
+thunk_getcounter(void)
{
- return clock_gettime(clock_id, tp);
+ struct timespec ts;
+ int error;
+
+ error = clock_gettime(CLOCK_MONOTONIC, &ts);
+ if (error) {
+ perror("clock_gettime CLOCK_MONOTONIC");
+ abort();
+ }
+
+ return (unsigned int)(ts.tv_sec * 1000000000ULL + ts.tv_nsec);
}
long