phunix/minix/lib/libsys/getuptime.c
David van Moolenbroek 25d39513e7 MIB: initial tree population
Change-Id: I28ef0a81a59faaf341bfc15178df89474779a136
2016-01-13 20:32:44 +01:00

25 lines
692 B
C

#include "sysutil.h"
/*
* Retrieve the system's uptime (number of clock ticks since system boot),
* real time (corrected number of clock ticks since system boot), and
* boot time (in number of seconds since the UNIX epoch).
*/
int
getuptime(clock_t * uptime, clock_t * realtime, time_t * boottime)
{
struct minix_kerninfo *minix_kerninfo;
minix_kerninfo = get_minix_kerninfo();
/* We assume atomic 32-bit field retrieval. TODO: 64-bit support. */
if (uptime != NULL)
*uptime = minix_kerninfo->kclockinfo->uptime;
if (realtime != NULL)
*realtime = minix_kerninfo->kclockinfo->realtime;
if (boottime != NULL)
*boottime = minix_kerninfo->kclockinfo->boottime;
return OK;
}