timerfd_settime32.c 976 B

1234567891011121314151617181920212223242526
  1. #include "time32.h"
  2. #include <time.h>
  3. #include <sys/timerfd.h>
  4. int __timerfd_settime32(int t, int flags, const struct itimerspec32 *restrict val32, struct itimerspec32 *restrict old32)
  5. {
  6. struct itimerspec old;
  7. int r = timerfd_settime(t, flags, (&(struct itimerspec){
  8. .it_interval.tv_sec = val32->it_interval.tv_sec,
  9. .it_interval.tv_nsec = val32->it_interval.tv_nsec,
  10. .it_value.tv_sec = val32->it_value.tv_sec,
  11. .it_value.tv_nsec = val32->it_value.tv_nsec}),
  12. old32 ? &old : 0);
  13. if (r) return r;
  14. /* The above call has already committed to success by changing the
  15. * timer setting, so we can't fail on out-of-range old value.
  16. * Since these are relative times, values large enough to overflow
  17. * don't make sense anyway. */
  18. if (old32) {
  19. old32->it_interval.tv_sec = old.it_interval.tv_sec;
  20. old32->it_interval.tv_nsec = old.it_interval.tv_nsec;
  21. old32->it_value.tv_sec = old.it_value.tv_sec;
  22. old32->it_value.tv_nsec = old.it_value.tv_nsec;
  23. }
  24. return 0;
  25. }