xref: /minix/minix/lib/libsys/getuptime.c (revision 0a6a1f1d)
1 #include "sysutil.h"
2 
3 /*
4  * Retrieve the system's uptime (number of clock ticks since system boot),
5  * real time (corrected number of clock ticks since system boot), and
6  * boot time (in number of seconds since the UNIX epoch).
7  */
8 int
9 getuptime(clock_t * uptime, clock_t * realtime, time_t * boottime)
10 {
11 	struct minix_kerninfo *minix_kerninfo;
12 
13 	minix_kerninfo = get_minix_kerninfo();
14 
15 	/* We assume atomic 32-bit field retrieval.  TODO: 64-bit support. */
16 	*uptime = minix_kerninfo->kclockinfo->uptime;
17 	*realtime = minix_kerninfo->kclockinfo->realtime;
18 	*boottime = minix_kerninfo->kclockinfo->boottime;
19 
20 	return OK;
21 }
22