Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/news68k/news68k Add workaround for volatile struct ...



details:   https://anonhg.NetBSD.org/src/rev/8a93c2b68a83
branches:  trunk
changeset: 581566:8a93c2b68a83
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Thu Jun 02 15:45:56 2005 +0000

description:
Add workaround for volatile struct timeval time vs. todr_*() function
prototype mismatch. Based on sparc64 fixes.

diffstat:

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

diffs (63 lines):

diff -r 99879d8154f6 -r 8a93c2b68a83 sys/arch/news68k/news68k/clock.c
--- a/sys/arch/news68k/news68k/clock.c  Thu Jun 02 15:44:20 2005 +0000
+++ b/sys/arch/news68k/news68k/clock.c  Thu Jun 02 15:45:56 2005 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: clock.c,v 1.13 2004/09/04 13:43:11 tsutsui Exp $      */
+/*      $NetBSD: clock.c,v 1.14 2005/06/02 15:45:56 tsutsui Exp $      */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.13 2004/09/04 13:43:11 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.14 2005/06/02 15:45:56 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -157,6 +157,7 @@
 void
 inittodr(time_t base)
 {
+       struct timeval tv;
        int badbase = 0, waszero = (base == 0);
 
        if (base < 5 * SECYR) {
@@ -172,8 +173,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
@@ -183,7 +184,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;
@@ -204,10 +208,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