diff options
author | Rich Felker <dalias@aerifal.cx> | 2019-08-05 19:55:42 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2019-08-05 21:16:30 -0400 |
commit | f522de81ac88dddb58266c15bcfaa044c4065e19 (patch) | |
tree | 10897524ab4ccb86b729adaba8363df914b531c2 /src | |
parent | 6818c31c9bc4bbad5357f1de14bedf781e5b349e (diff) | |
download | musl-f522de81ac88dddb58266c15bcfaa044c4065e19.tar.gz musl-f522de81ac88dddb58266c15bcfaa044c4065e19.tar.bz2 musl-f522de81ac88dddb58266c15bcfaa044c4065e19.tar.xz musl-f522de81ac88dddb58266c15bcfaa044c4065e19.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/unistd/alarm.c | 6 |
1 files changed, 3 insertions, 3 deletions
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; } |