summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/unistd/alarm.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc-top-half/musl/src/unistd/alarm.c')
-rw-r--r--libc-top-half/musl/src/unistd/alarm.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/unistd/alarm.c b/libc-top-half/musl/src/unistd/alarm.c
new file mode 100644
index 0000000..a5e0c82
--- /dev/null
+++ b/libc-top-half/musl/src/unistd/alarm.c
@@ -0,0 +1,10 @@
+#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;
+}