xref: /minix3/minix/lib/libsys/getuptime.c (revision d2532d3d42d764c9ef9816851cdb17eda7e08d36)
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 	if (uptime != NULL)
17 		*uptime = minix_kerninfo->kclockinfo->uptime;
18 	if (realtime != NULL)
19 		*realtime = minix_kerninfo->kclockinfo->realtime;
20 	if (boottime != NULL)
21 		*boottime = minix_kerninfo->kclockinfo->boottime;
22 
23 	return OK;
24 }
25