diff options
Diffstat (limited to 'libc-top-half/musl/compat/time32/setitimer_time32.c')
-rw-r--r-- | libc-top-half/musl/compat/time32/setitimer_time32.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libc-top-half/musl/compat/time32/setitimer_time32.c b/libc-top-half/musl/compat/time32/setitimer_time32.c new file mode 100644 index 0000000..2475fd8 --- /dev/null +++ b/libc-top-half/musl/compat/time32/setitimer_time32.c @@ -0,0 +1,25 @@ +#include "time32.h" +#include <time.h> +#include <sys/time.h> + +int __setitimer_time32(int which, const struct itimerval32 *restrict new32, struct itimerval32 *restrict old32) +{ + struct itimerval old; + int r = setitimer(which, (&(struct itimerval){ + .it_interval.tv_sec = new32->it_interval.tv_sec, + .it_interval.tv_usec = new32->it_interval.tv_usec, + .it_value.tv_sec = new32->it_value.tv_sec, + .it_value.tv_usec = new32->it_value.tv_usec}), &old); + if (r) return r; + /* The above call has already committed to success by changing the + * timer setting, so we can't fail on out-of-range old value. + * Since these are relative times, values large enough to overflow + * don't make sense anyway. */ + if (old32) { + old32->it_interval.tv_sec = old.it_interval.tv_sec; + old32->it_interval.tv_usec = old.it_interval.tv_usec; + old32->it_value.tv_sec = old.it_value.tv_sec; + old32->it_value.tv_usec = old.it_value.tv_usec; + } + return 0; +} |