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 time_t fixes



details:   https://anonhg.NetBSD.org/src/rev/40033f68cc67
branches:  trunk
changeset: 768647:40033f68cc67
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Tue Aug 23 17:00:36 2011 +0000

description:
more time_t fixes

diffstat:

 sys/arch/usermode/dev/clock.c        |   6 ++--
 sys/arch/usermode/include/thunk.h    |   9 ++++-
 sys/arch/usermode/usermode/machdep.c |   6 ++--
 sys/arch/usermode/usermode/thunk.c   |  51 +++++++++++++++++++++++++++++++----
 4 files changed, 57 insertions(+), 15 deletions(-)

diffs (158 lines):

diff -r 4bc1cd6d6074 -r 40033f68cc67 sys/arch/usermode/dev/clock.c
--- a/sys/arch/usermode/dev/clock.c     Tue Aug 23 16:16:43 2011 +0000
+++ b/sys/arch/usermode/dev/clock.c     Tue Aug 23 17:00:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: clock.c,v 1.10 2011/08/23 16:09:27 jmcneill Exp $ */
+/* $NetBSD: clock.c,v 1.11 2011/08/23 17:00:36 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.10 2011/08/23 16:09:27 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.11 2011/08/23 17:00:36 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -83,7 +83,7 @@
 clock_attach(device_t parent, device_t self, void *opaque)
 {
        clock_softc_t *sc = device_private(self);
-       struct itimerval itimer;
+       struct thunk_itimerval itimer;
        long tcres;
 
        aprint_naive("\n");
diff -r 4bc1cd6d6074 -r 40033f68cc67 sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Tue Aug 23 16:16:43 2011 +0000
+++ b/sys/arch/usermode/include/thunk.h Tue Aug 23 17:00:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.12 2011/08/23 16:16:26 jmcneill Exp $ */
+/* $NetBSD: thunk.h,v 1.13 2011/08/23 17:00:36 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -43,7 +43,12 @@
        int32_t tv_usec;
 };
 
-int    thunk_setitimer(int, const struct itimerval *, struct itimerval *);
+struct thunk_itimerval {
+       struct thunk_timeval it_interval;
+       struct thunk_timeval it_value;
+};
+
+int    thunk_setitimer(int, const struct thunk_itimerval *, struct thunk_itimerval *);
 int    thunk_gettimeofday(struct thunk_timeval *, void *);
 unsigned int thunk_getcounter(void);
 long   thunk_clock_getres_monotonic(void);
diff -r 4bc1cd6d6074 -r 40033f68cc67 sys/arch/usermode/usermode/machdep.c
--- a/sys/arch/usermode/usermode/machdep.c      Tue Aug 23 16:16:43 2011 +0000
+++ b/sys/arch/usermode/usermode/machdep.c      Tue Aug 23 17:00:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.13 2011/08/13 10:31:24 jmcneill Exp $ */
+/* $NetBSD: machdep.c,v 1.14 2011/08/23 17:00:36 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.13 2011/08/13 10:31:24 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.14 2011/08/23 17:00:36 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -102,7 +102,7 @@
 void
 usermode_reboot(void)
 {
-       struct itimerval itimer;
+       struct thunk_itimerval itimer;
 
        /* make sure the timer is turned off */
        memset(&itimer, 0, sizeof(itimer));
diff -r 4bc1cd6d6074 -r 40033f68cc67 sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c        Tue Aug 23 16:16:43 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c        Tue Aug 23 17:00:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.13 2011/08/23 16:16:26 jmcneill Exp $ */
+/* $NetBSD: thunk.c,v 1.14 2011/08/23 17:00:36 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.13 2011/08/23 16:16:26 jmcneill Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.14 2011/08/23 17:00:36 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/ansi.h>
@@ -46,11 +46,49 @@
 
 #include "../include/thunk.h"
 
+static void
+thunk_to_timeval(const struct thunk_timeval *ttv, struct timeval *tv)
+{
+       tv->tv_sec = ttv->tv_sec;
+       tv->tv_usec = ttv->tv_usec;
+}
+
+static void
+thunk_from_timeval(const struct timeval *tv, struct thunk_timeval *ttv)
+{
+       ttv->tv_sec = tv->tv_sec;
+       ttv->tv_usec = tv->tv_usec;
+}
+
+static void
+thunk_to_itimerval(const struct thunk_itimerval *tit, struct itimerval *it)
+{
+       thunk_to_timeval(&tit->it_interval, &it->it_interval);
+       thunk_to_timeval(&tit->it_value, &it->it_value);
+}
+
+static void
+thunk_from_itimerval(const struct itimerval *it, struct thunk_itimerval *tit)
+{
+       thunk_from_timeval(&it->it_interval, &tit->it_interval);
+       thunk_from_timeval(&it->it_value, &tit->it_value);
+}
+
 int
-thunk_setitimer(int which, const struct itimerval *value,
-    struct itimerval *ovalue)
+thunk_setitimer(int which, const struct thunk_itimerval *value,
+    struct thunk_itimerval *ovalue)
 {
-       return setitimer(which, value, ovalue);
+       struct itimerval it, oit;
+       int error;
+
+       thunk_to_itimerval(value, &it);
+       error = setitimer(which, &it, &oit);
+       if (error)
+               return error;
+       if (ovalue)
+               thunk_from_itimerval(&oit, ovalue);
+
+       return 0;
 }
 
 int
@@ -63,8 +101,7 @@
        if (error)
                return error;
 
-       tp->tv_sec = tv.tv_sec;
-       tp->tv_usec = tv.tv_usec;
+       thunk_from_timeval(&tv, tp);
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index