remove wrap_write helper from vdprintf
[musl.git] / src / signal / setitimer.c
blob0dfbeb4db5a7ad65faeac76e6039a11807645f2b
1 #include <sys/time.h>
2 #include <errno.h>
3 #include "syscall.h"
5 #define IS32BIT(x) !((x)+0x80000000ULL>>32)
7 int setitimer(int which, const struct itimerval *restrict new, struct itimerval *restrict old)
9 if (sizeof(time_t) > sizeof(long)) {
10 time_t is = new->it_interval.tv_sec, vs = new->it_value.tv_sec;
11 long ius = new->it_interval.tv_usec, vus = new->it_value.tv_usec;
12 if (!IS32BIT(is) || !IS32BIT(vs))
13 return __syscall_ret(-ENOTSUP);
14 long old32[4];
15 int r = __syscall(SYS_setitimer, which,
16 ((long[]){is, ius, vs, vus}), old32);
17 if (!r && old) {
18 old->it_interval.tv_sec = old32[0];
19 old->it_interval.tv_usec = old32[1];
20 old->it_value.tv_sec = old32[2];
21 old->it_value.tv_usec = old32[3];
23 return __syscall_ret(r);
25 return syscall(SYS_setitimer, which, new, old);