6 * This routine returns the time in seconds since 1.1.1970. MINIX is an
7 * astrophysically naive system that assumes the earth rotates at a constant
8 * rate and that such things as leap seconds do not exist. If a non-NULL
9 * pointer to a timespec structure is given, that structure is filled with
10 * the current time in subsecond precision.
13 clock_time(struct timespec
*tv
)
15 struct minix_kerninfo
*minix_kerninfo
;
20 minix_kerninfo
= get_minix_kerninfo();
22 /* We assume atomic 32-bit field retrieval. TODO: 64-bit support. */
23 boottime
= minix_kerninfo
->kclockinfo
->boottime
;
24 realtime
= minix_kerninfo
->kclockinfo
->realtime
;
25 system_hz
= minix_kerninfo
->kclockinfo
->hz
;
27 sec
= boottime
+ realtime
/ system_hz
;
33 * We do not want to overflow, and system_hz can be as high as
36 if (system_hz
< LONG_MAX
/ 40000)
37 tv
->tv_nsec
= (realtime
% system_hz
) * 40000 /
40 tv
->tv_nsec
= 0; /* bad, but what's better? */