xref: /minix3/minix/lib/libsys/sys_setalarm.c (revision cfd712b4245f67a5631cc14e950ce43b18455602)
1433d6423SLionel Sambuc #include "syslib.h"
2433d6423SLionel Sambuc 
3e10ce184SDavid van Moolenbroek /*
4e10ce184SDavid van Moolenbroek  * Ask the kernel to schedule a synchronous alarm for the caller, using either
5*cfd712b4SDavid van Moolenbroek  * an absolute or a relative number of clock ticks.  The new alarm replaces any
6*cfd712b4SDavid van Moolenbroek  * previously set alarm.  If a relative expiry time of zero is given, the
7*cfd712b4SDavid van Moolenbroek  * current alarm is stopped.  Return OK or a negative error code.  On success,
8*cfd712b4SDavid van Moolenbroek  * optionally return the time left on the previous timer (TMR_NEVER if none was
9*cfd712b4SDavid van Moolenbroek  * set) and the current time.
10433d6423SLionel Sambuc  */
11e10ce184SDavid van Moolenbroek int
sys_setalarm2(clock_t exp_time,int abs_time,clock_t * time_left,clock_t * uptime)12e10ce184SDavid van Moolenbroek sys_setalarm2(clock_t exp_time, int abs_time, clock_t * time_left,
13e10ce184SDavid van Moolenbroek 	clock_t * uptime)
14e10ce184SDavid van Moolenbroek {
15433d6423SLionel Sambuc 	message m;
16e10ce184SDavid van Moolenbroek 	int r;
17e10ce184SDavid van Moolenbroek 
18e10ce184SDavid van Moolenbroek 	m.m_lsys_krn_sys_setalarm.exp_time = exp_time; /* expiration time */
19433d6423SLionel Sambuc 	m.m_lsys_krn_sys_setalarm.abs_time = abs_time; /* time is absolute? */
20e10ce184SDavid van Moolenbroek 
21e10ce184SDavid van Moolenbroek 	if ((r = _kernel_call(SYS_SETALARM, &m)) != OK)
22e10ce184SDavid van Moolenbroek 		return r;
23e10ce184SDavid van Moolenbroek 
24e10ce184SDavid van Moolenbroek 	if (time_left != NULL)
25e10ce184SDavid van Moolenbroek 		*time_left = m.m_lsys_krn_sys_setalarm.time_left;
26e10ce184SDavid van Moolenbroek 	if (uptime != NULL)
27e10ce184SDavid van Moolenbroek 		*uptime = m.m_lsys_krn_sys_setalarm.uptime;
28e10ce184SDavid van Moolenbroek 	return OK;
29433d6423SLionel Sambuc }
30