xref: /minix/minix/lib/libsys/sys_setalarm.c (revision 0a6a1f1d)
1 #include "syslib.h"
2 
3 /*
4  * Ask the kernel to schedule a synchronous alarm for the caller, using either
5  * an absolute or a relative number of clock ticks.  Optionally return the time
6  * left on the previous timer (TMR_NEVER if none was set) and the current time.
7  */
8 int
9 sys_setalarm2(clock_t exp_time, int abs_time, clock_t * time_left,
10 	clock_t * uptime)
11 {
12 	message m;
13 	int r;
14 
15 	m.m_lsys_krn_sys_setalarm.exp_time = exp_time; /* expiration time */
16 	m.m_lsys_krn_sys_setalarm.abs_time = abs_time; /* time is absolute? */
17 
18 	if ((r = _kernel_call(SYS_SETALARM, &m)) != OK)
19 		return r;
20 
21 	if (time_left != NULL)
22 		*time_left = m.m_lsys_krn_sys_setalarm.time_left;
23 	if (uptime != NULL)
24 		*uptime = m.m_lsys_krn_sys_setalarm.uptime;
25 	return OK;
26 }
27