X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=blobdiff_plain;f=src%2Fdevices%2Frtc.c;h=745d779eebf7010f8ef31b7fb5c1fe7fc405e765;hp=d99eb4679f1c9da0eed03412062f84209666cfd3;hb=919347c164606c3f1544b2e8bd62f505aeda80a1;hpb=9f013d0930202eea99c21083b71098a0df64be0d diff --git a/src/devices/rtc.c b/src/devices/rtc.c index d99eb46..745d779 100644 --- a/src/devices/rtc.c +++ b/src/devices/rtc.c @@ -1,4 +1,5 @@ #include "devices/rtc.h" +#include #include #include "threads/io.h" @@ -82,10 +83,10 @@ rtc_get_time (void) year -= 70; /* Break down all components into seconds. */ - time = (year * 365 + (year - 1) / 4) * 24 * 60 * 60; - for (i = 1; i <= mon; i++) + time = (year * 365 + DIV_ROUND_UP (year - 2, 4)) * 24 * 60 * 60; + for (i = 1; i < mon; i++) time += days_per_month[i - 1] * 24 * 60 * 60; - if (mon > 2 && year % 4 == 0) + if (mon > 2 && year % 4 == 2) time += 24 * 60 * 60; time += (mday - 1) * 24 * 60 * 60; time += hour * 60 * 60;