From f3590c636b070b5af4e003cf4ac0f5f938feb849 Mon Sep 17 00:00:00 2001 From: itohy Date: Mon, 15 Jan 2001 07:04:41 +0000 Subject: [PATCH] Make it compile with "options DIAGNOSTIC" (patch from minoura). --- sys/arch/x68k/dev/rtclock.c | 11 ++++++----- sys/arch/x68k/dev/rtclock_var.h | 10 +++++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/sys/arch/x68k/dev/rtclock.c b/sys/arch/x68k/dev/rtclock.c index d176a1827578..bf6bac3a6668 100644 --- a/sys/arch/x68k/dev/rtclock.c +++ b/sys/arch/x68k/dev/rtclock.c @@ -1,4 +1,4 @@ -/* $NetBSD: rtclock.c,v 1.8 2001/01/11 16:09:42 minoura Exp $ */ +/* $NetBSD: rtclock.c,v 1.9 2001/01/15 07:04:41 itohy Exp $ */ /* * Copyright 1993, 1994 Masaru Oki @@ -149,16 +149,17 @@ rtgettod() dt.dt_hour = RTC_REG(RTC_HOUR10) * 10 + RTC_REG(RTC_HOUR); dt.dt_day = RTC_REG(RTC_DAY10) * 10 + RTC_REG(RTC_DAY); dt.dt_mon = RTC_REG(RTC_MON10) * 10 + RTC_REG(RTC_MON); - dt.dt_year = RTC_REG(RTC_YEAR10) * 10 + RTC_REG(RTC_YEAR) + 1980; + dt.dt_year = RTC_REG(RTC_YEAR10) * 10 + RTC_REG(RTC_YEAR) + +RTC_BASE_YEAR; /* let it run again.. */ RTC_WRITE(RTC_MODE, RTC_FREE_CLOCK); #ifdef DIAGNOSTIC - range_test(dt.dt_hour, 0, 23); + range_test0(dt.dt_hour, 23); range_test(dt.dt_day, 1, 31); range_test(dt.dt_mon, 1, 12); - range_test(dt.dt_year, STARTOFTIME, 2079); + range_test(dt.dt_year, RTC_BASE_YEAR, RTC_BASE_YEAR+100-1); #endif return clock_ymdhms_to_secs (&dt); @@ -190,7 +191,7 @@ rtsettod (tim) day2 = dt.dt_day % 10; mon1 = dt.dt_mon / 10; mon2 = dt.dt_mon % 10; - year1 = (dt.dt_year - 1980) / 10; + year1 = (dt.dt_year - RTC_BASE_YEAR) / 10; year2 = dt.dt_year % 10; RTC_WRITE(RTC_MODE, RTC_HOLD_CLOCK); diff --git a/sys/arch/x68k/dev/rtclock_var.h b/sys/arch/x68k/dev/rtclock_var.h index b2ecd8c9e128..b51cb789f077 100644 --- a/sys/arch/x68k/dev/rtclock_var.h +++ b/sys/arch/x68k/dev/rtclock_var.h @@ -1,4 +1,4 @@ -/* $NetBSD: rtclock_var.h,v 1.3 2001/01/11 16:09:43 minoura Exp $ */ +/* $NetBSD: rtclock_var.h,v 1.4 2001/01/15 07:04:41 itohy Exp $ */ /* * Copyright 1993, 1994 Masaru Oki @@ -30,6 +30,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* + * Should be splitted to _reg.h and _var.h + */ + #ifndef _RTCLOCKVAR_H_ #define _RTCLOCKVAR_H_ @@ -86,6 +90,10 @@ struct rtc_softc { #define RTC_LEAP 0x17 #define RTC_UNUSED2 0x19 +#define RTC_BASE_YEAR 1980 + #define range_test(n, l, h) if ((n) < (l) || (n) > (h)) return(0) +#define range_test0(n, h) if ((unsigned)(n) > (h)) return(0) + /* cast to unsigned in case n is signed */ #endif /* _RTCLOCKVAR_H_ */