Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arc/arc workaround for volatile struct timeval time...



details:   https://anonhg.NetBSD.org/src/rev/de86dbed55d8
branches:  trunk
changeset: 581636:de86dbed55d8
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Fri Jun 03 12:32:44 2005 +0000

description:
workaround for volatile struct timeval time vs todr_*() arg mismatch.

diffstat:

 sys/arch/arc/arc/todclock.c |  18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diffs (63 lines):

diff -r c056fbe4c332 -r de86dbed55d8 sys/arch/arc/arc/todclock.c
--- a/sys/arch/arc/arc/todclock.c       Fri Jun 03 12:31:38 2005 +0000
+++ b/sys/arch/arc/arc/todclock.c       Fri Jun 03 12:32:44 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: todclock.c,v 1.6 2005/01/22 07:35:33 tsutsui Exp $ */
+/* $NetBSD: todclock.c,v 1.7 2005/06/03 12:32:44 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: todclock.c,v 1.6 2005/01/22 07:35:33 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: todclock.c,v 1.7 2005/06/03 12:32:44 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -71,6 +71,7 @@
 void
 inittodr(time_t base)
 {
+       struct timeval tv;
        int badbase, waszero;
 
        badbase = 0;
@@ -89,8 +90,8 @@
                badbase = 1;
        }
 
-       if (todr_gettime(todr_handle, (struct timeval *)&time) != 0 ||
-           time.tv_sec == 0) {
+       if (todr_gettime(todr_handle, &tv) != 0 ||
+           tv.tv_sec == 0) {
                printf("WARNING: bad date in battery clock");
                /*
                 * Believe the time in the file system for lack of
@@ -100,7 +101,10 @@
                if (!badbase)
                        resettodr();
        } else {
-               int deltat = time.tv_sec - base;
+               int deltat;
+
+               time = tv;
+               deltat = time.tv_sec - base;
 
                if (deltat < 0)
                        deltat = -deltat;
@@ -121,10 +125,12 @@
 void
 resettodr(void)
 {
+       struct timeval tv;
 
        if (time.tv_sec == 0)
                return;
 
-       if (todr_settime(todr_handle, (struct timeval *)&time) != 0)
+       tv = time;
+       if (todr_settime(todr_handle, &tv) != 0)
                printf("resettodr: cannot set time in time-of-day clock\n");
 }



Home | Main Index | Thread Index | Old Index