Make it compile with "options DIAGNOSTIC" (patch from minoura).

This commit is contained in:
itohy 2001-01-15 07:04:41 +00:00
parent a88307ab86
commit f3590c636b
2 changed files with 15 additions and 6 deletions

View File

@ -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);

View File

@ -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_ */