define NULL as nullptr when used in C++11 or later
[musl] / src / unistd / alarm.c
index bba444d..a5e0c82 100644 (file)
@@ -1,7 +1,10 @@
 #include <unistd.h>
+#include <sys/time.h>
 #include "syscall.h"
 
 unsigned alarm(unsigned seconds)
 {
-       return syscall1(__NR_alarm, 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;
 }