musl-tcc/src/unistd/alarm.c

11 lines
259 B
C
Raw Normal View History

2022-03-20 04:48:53 -04:00
#include <unistd.h>
#include <sys/time.h>
#include "syscall.h"
unsigned alarm(unsigned seconds)
{
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;
}