Module Name:    src
Committed By:   jmcneill
Date:           Tue Aug 23 16:09:27 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:
more host vs. userkernel time_t fixes


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/usermode/dev/clock.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.11 -r1.12 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.9 src/sys/arch/usermode/dev/clock.c:1.10
--- src/sys/arch/usermode/dev/clock.c:1.9	Tue Aug 23 14:37:50 2011
+++ src/sys/arch/usermode/dev/clock.c	Tue Aug 23 16:09:27 2011
@@ -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 <jmcne...@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 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 @@
 	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;
 }

Index: src/sys/arch/usermode/include/thunk.h
diff -u src/sys/arch/usermode/include/thunk.h:1.10 src/sys/arch/usermode/include/thunk.h:1.11
--- src/sys/arch/usermode/include/thunk.h:1.10	Tue Aug 23 14:37:50 2011
+++ src/sys/arch/usermode/include/thunk.h	Tue Aug 23 16:09:27 2011
@@ -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 <jmcne...@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);
 

Index: src/sys/arch/usermode/usermode/thunk.c
diff -u src/sys/arch/usermode/usermode/thunk.c:1.11 src/sys/arch/usermode/usermode/thunk.c:1.12
--- src/sys/arch/usermode/usermode/thunk.c:1.11	Tue Aug 23 14:37:50 2011
+++ src/sys/arch/usermode/usermode/thunk.c	Tue Aug 23 16:09:27 2011
@@ -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 <jmcne...@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 @@
 }
 
 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

Reply via email to