remove another invalid skip of locking in ungetwc
[oweals/musl.git] / src / unistd / alarm.c
index bba444d8721774f6b78b626c88356636ae6094e5..2e3263ac5986019f57576f6b0777f483b449eba7 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 };
+       __syscall(SYS_setitimer, ITIMER_REAL, &it, &it);
+       return it.it_value.tv_sec + !!it.it_value.tv_usec;
 }