Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/usermode more host vs. userkernel time_t fixes
details: https://anonhg.NetBSD.org/src/rev/6e2fea73dcb0
branches: trunk
changeset: 768644:6e2fea73dcb0
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Tue Aug 23 16:09:27 2011 +0000
description:
more host vs. userkernel time_t fixes
diffstat:
sys/arch/usermode/dev/clock.c | 25 ++++++++++++++++---------
sys/arch/usermode/include/thunk.h | 11 ++++++++---
sys/arch/usermode/usermode/thunk.c | 33 ++++++++++++++++++++++++++-------
3 files changed, 50 insertions(+), 19 deletions(-)
diffs (142 lines):
diff -r 773fa639262c -r 6e2fea73dcb0 sys/arch/usermode/dev/clock.c
--- a/sys/arch/usermode/dev/clock.c Tue Aug 23 15:56:12 2011 +0000
+++ b/sys/arch/usermode/dev/clock.c Tue Aug 23 16:09:27 2011 +0000
@@ -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@localhost>
@@ -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;
}
diff -r 773fa639262c -r 6e2fea73dcb0 sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Tue Aug 23 15:56:12 2011 +0000
+++ b/sys/arch/usermode/include/thunk.h Tue Aug 23 16:09:27 2011 +0000
@@ -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@localhost>
@@ -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 -r 773fa639262c -r 6e2fea73dcb0 sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c Tue Aug 23 15:56:12 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c Tue Aug 23 16:09:27 2011 +0000
@@ -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@localhost>
@@ -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
Home |
Main Index |
Thread Index |
Old Index