projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rtc: Fix Unix epoch conversion from RTC time.
[pintos-anon]
/
src
/
devices
/
rtc.c
diff --git
a/src/devices/rtc.c
b/src/devices/rtc.c
index d99eb4679f1c9da0eed03412062f84209666cfd3..745d779eebf7010f8ef31b7fb5c1fe7fc405e765 100644
(file)
--- a/
src/devices/rtc.c
+++ b/
src/devices/rtc.c
@@
-1,4
+1,5
@@
#include "devices/rtc.h"
#include "devices/rtc.h"
+#include <round.h>
#include <stdio.h>
#include "threads/io.h"
#include <stdio.h>
#include "threads/io.h"
@@
-82,10
+83,10
@@
rtc_get_time (void)
year -= 70;
/* Break down all components into seconds. */
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;
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;
time += 24 * 60 * 60;
time += (mday - 1) * 24 * 60 * 60;
time += hour * 60 * 60;