1570af302Sopenharmony_ci#include "time32.h" 2570af302Sopenharmony_ci#include <time.h> 3570af302Sopenharmony_ci#include <sys/timerfd.h> 4570af302Sopenharmony_ci 5570af302Sopenharmony_ciint __timerfd_settime32(int t, int flags, const struct itimerspec32 *restrict val32, struct itimerspec32 *restrict old32) 6570af302Sopenharmony_ci{ 7570af302Sopenharmony_ci struct itimerspec old; 8570af302Sopenharmony_ci int r = timerfd_settime(t, flags, (&(struct itimerspec){ 9570af302Sopenharmony_ci .it_interval.tv_sec = val32->it_interval.tv_sec, 10570af302Sopenharmony_ci .it_interval.tv_nsec = val32->it_interval.tv_nsec, 11570af302Sopenharmony_ci .it_value.tv_sec = val32->it_value.tv_sec, 12570af302Sopenharmony_ci .it_value.tv_nsec = val32->it_value.tv_nsec}), 13570af302Sopenharmony_ci old32 ? &old : 0); 14570af302Sopenharmony_ci if (r) return r; 15570af302Sopenharmony_ci /* The above call has already committed to success by changing the 16570af302Sopenharmony_ci * timer setting, so we can't fail on out-of-range old value. 17570af302Sopenharmony_ci * Since these are relative times, values large enough to overflow 18570af302Sopenharmony_ci * don't make sense anyway. */ 19570af302Sopenharmony_ci if (old32) { 20570af302Sopenharmony_ci old32->it_interval.tv_sec = old.it_interval.tv_sec; 21570af302Sopenharmony_ci old32->it_interval.tv_nsec = old.it_interval.tv_nsec; 22570af302Sopenharmony_ci old32->it_value.tv_sec = old.it_value.tv_sec; 23570af302Sopenharmony_ci old32->it_value.tv_nsec = old.it_value.tv_nsec; 24570af302Sopenharmony_ci } 25570af302Sopenharmony_ci return 0; 26570af302Sopenharmony_ci} 27