otherwise alarm will break on 32-bit archs when time_t is changed to
64-bit. a second itimerval object is introduced for retrieving the old
value, since the setitimer function has restrict-qualified arguments.
unsigned alarm(unsigned seconds)
{
- struct itimerval it = { .it_value.tv_sec = seconds };
- __syscall(SYS_setitimer, ITIMER_REAL, &it, &it);
- return it.it_value.tv_sec + !!it.it_value.tv_usec;
+ struct itimerval it = { .it_value.tv_sec = seconds }, old = { 0 };
+ setitimer(ITIMER_REAL, &it, &old);
+ return old.it_value.tv_sec + !!old.it_value.tv_usec;
}