diff options
Diffstat (limited to 'compat/time32/timerfd_settime32.c')
-rw-r--r-- | compat/time32/timerfd_settime32.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/compat/time32/timerfd_settime32.c b/compat/time32/timerfd_settime32.c new file mode 100644 index 00000000..67830d34 --- /dev/null +++ b/compat/time32/timerfd_settime32.c @@ -0,0 +1,26 @@ +#include "time32.h" +#include <time.h> +#include <sys/timerfd.h> + +int __timerfd_settime32(int t, int flags, const struct itimerspec32 *restrict val32, struct itimerspec32 *restrict old32) +{ + struct itimerspec old; + int r = timerfd_settime(t, flags, (&(struct itimerspec){ + .it_interval.tv_sec = val32->it_interval.tv_sec, + .it_interval.tv_nsec = val32->it_interval.tv_nsec, + .it_value.tv_sec = val32->it_value.tv_sec, + .it_value.tv_nsec = val32->it_value.tv_nsec}), + old32 ? &old : 0); + 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_nsec = old.it_interval.tv_nsec; + old32->it_value.tv_sec = old.it_value.tv_sec; + old32->it_value.tv_nsec = old.it_value.tv_nsec; + } + return 0; +} |