1 #include <sys/cdefs.h>
2 #include "namespace.h"
3 #include <lib.h>
4
5 #include <string.h>
6 #include <sys/time.h>
7
8 /*
9 * This is the implementation of the function to
10 * invoke the interval timer setting system call.
11 */
setitimer(int which,const struct itimerval * __restrict value,struct itimerval * __restrict ovalue)12 int setitimer(int which, const struct itimerval *__restrict value,
13 struct itimerval *__restrict ovalue)
14 {
15 message m;
16
17 /* A null pointer for 'value' would make setitimer behave like getitimer,
18 * which is not according to the specification, so disallow null pointers.
19 */
20 if (value == NULL) {
21 errno = EINVAL;
22 return -1;
23 }
24
25 memset(&m, 0, sizeof(m));
26 m.m_lc_pm_itimer.which = which;
27 m.m_lc_pm_itimer.value = (vir_bytes)value;
28 m.m_lc_pm_itimer.ovalue = (vir_bytes)ovalue;
29
30 return _syscall(PM_PROC_NR, PM_ITIMER, &m);
31 }
32
33 #if defined(__minix) && defined(__weak_alias)
34 __weak_alias(setitimer, __setitimer50)
35 #endif
36