From: Rich Felker Date: Mon, 5 Aug 2019 23:55:42 +0000 (-0400) Subject: use setitimer function rather than syscall to implement alarm X-Git-Tag: v1.1.24~56 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f522de81ac88dddb58266c15bcfaa044c4065e19;p=oweals%2Fmusl.git use setitimer function rather than syscall to implement alarm 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. --- diff --git a/src/unistd/alarm.c b/src/unistd/alarm.c index 2e3263ac..a5e0c822 100644 --- a/src/unistd/alarm.c +++ b/src/unistd/alarm.c @@ -4,7 +4,7 @@ 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; }