From: David van Moolenbroek Date: Sun, 30 Aug 2009 16:06:59 +0000 (+0000) Subject: Fix time(1) for custom system HZ values (reported by Jose Luis Sanchez X-Git-Tag: v3.1.5~167 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/named.html?a=commitdiff_plain;h=a57fbb11cdcb5e2e97cc10f0e96552f4a6666bb1;p=minix.git Fix time(1) for custom system HZ values (reported by Jose Luis Sanchez --- diff --git a/commands/simple/time.c b/commands/simple/time.c index 49d8e2e22..7860062b5 100755 --- a/commands/simple/time.c +++ b/commands/simple/time.c @@ -11,6 +11,7 @@ #include #include #include +#include #include /* -DNEW prints time to 0.01 sec. */ @@ -108,16 +109,19 @@ register clock_t t; /* Print the time 't' in hours: minutes: seconds. 't' is in ticks. */ int hours, minutes, seconds, hundredths, i; + u32_t system_hz; + + getsysinfo_up(PM_PROC_NR, SIU_SYSTEMHZ, sizeof(system_hz), &system_hz); digit_seen = 0; for (i = 0; i < 8; i++) a[i] = ' '; - hours = (int) (t / ((clock_t) 3600 * CLOCKS_PER_SEC)); - t -= (clock_t) hours * 3600 * CLOCKS_PER_SEC; - minutes = (int) (t / ((clock_t) 60 * CLOCKS_PER_SEC)); - t -= (clock_t) minutes * 60 * CLOCKS_PER_SEC; - seconds = (int) (t / CLOCKS_PER_SEC); - t -= (clock_t) seconds * CLOCKS_PER_SEC; - hundredths = (int) (t * 100 / CLOCKS_PER_SEC); + hours = (int) (t / ((clock_t) 3600 * system_hz)); + t -= (clock_t) hours * 3600 * system_hz; + minutes = (int) (t / ((clock_t) 60 * system_hz)); + t -= (clock_t) minutes * 60 * system_hz; + seconds = (int) (t / system_hz); + t -= (clock_t) seconds * system_hz; + hundredths = (int) (t * 100 / system_hz); if (hours) { twin(hours, &a[0]);