1
0

timer_settime32.c 951 B

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