diff options
author | bde <bde@FreeBSD.org> | 1996-01-12 17:33:12 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1996-01-12 17:33:12 +0000 |
commit | 8a56d80536a9c47a9ef32de457cc2fa72ed09f42 (patch) | |
tree | c5eda996880cd6a8e329824caf368f96b7c0d4d5 /sys/amd64 | |
parent | f431f4ad25d343a614a2a09976c4ed0aa8a70460 (diff) | |
download | FreeBSD-src-8a56d80536a9c47a9ef32de457cc2fa72ed09f42.zip FreeBSD-src-8a56d80536a9c47a9ef32de457cc2fa72ed09f42.tar.gz |
Fixed handling of Feb 29 in resettodr().
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/amd64/tsc.c | 16 | ||||
-rw-r--r-- | sys/amd64/isa/clock.c | 16 |
2 files changed, 22 insertions, 10 deletions
diff --git a/sys/amd64/amd64/tsc.c b/sys/amd64/amd64/tsc.c index 487e7bc..869fd0b 100644 --- a/sys/amd64/amd64/tsc.c +++ b/sys/amd64/amd64/tsc.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.44 1996/01/04 21:11:33 wollman Exp $ + * $Id: clock.c,v 1.45 1996/01/08 18:50:14 ache Exp $ */ /* @@ -541,10 +541,16 @@ resettodr() #else writertc(RTC_YEAR, int2bcd(y - 1900)); /* Write back Year */ #endif - if (LEAPYEAR(y) && (tm >= 31+29)) - tm--; /* Subtract Feb-29 */ - for (m = 0; tm >= daysinmonth[m]; m++) - tm -= daysinmonth[m]; + for (m = 0; ; m++) { + int ml; + + ml = daysinmonth[m]; + if (m == 1 && LEAPYEAR(y)) + ml++; + if (tm < ml) + break; + tm -= ml; + } writertc(RTC_MONTH, int2bcd(m + 1)); /* Write back Month */ writertc(RTC_DAY, int2bcd(tm + 1)); /* Write back Month Day */ diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c index 487e7bc..869fd0b 100644 --- a/sys/amd64/isa/clock.c +++ b/sys/amd64/isa/clock.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.44 1996/01/04 21:11:33 wollman Exp $ + * $Id: clock.c,v 1.45 1996/01/08 18:50:14 ache Exp $ */ /* @@ -541,10 +541,16 @@ resettodr() #else writertc(RTC_YEAR, int2bcd(y - 1900)); /* Write back Year */ #endif - if (LEAPYEAR(y) && (tm >= 31+29)) - tm--; /* Subtract Feb-29 */ - for (m = 0; tm >= daysinmonth[m]; m++) - tm -= daysinmonth[m]; + for (m = 0; ; m++) { + int ml; + + ml = daysinmonth[m]; + if (m == 1 && LEAPYEAR(y)) + ml++; + if (tm < ml) + break; + tm -= ml; + } writertc(RTC_MONTH, int2bcd(m + 1)); /* Write back Month */ writertc(RTC_DAY, int2bcd(tm + 1)); /* Write back Month Day */ |