1570af302Sopenharmony_ci#include <sys/time.h> 2570af302Sopenharmony_ci#include <errno.h> 3570af302Sopenharmony_ci#include "syscall.h" 4570af302Sopenharmony_ci 5570af302Sopenharmony_ci#define IS32BIT(x) !((x)+0x80000000ULL>>32) 6570af302Sopenharmony_ci 7570af302Sopenharmony_ciint setitimer(int which, const struct itimerval *restrict new, struct itimerval *restrict old) 8570af302Sopenharmony_ci{ 9570af302Sopenharmony_ci#ifndef __LITEOS_A__ 10570af302Sopenharmony_ci if (sizeof(time_t) > sizeof(long)) { 11570af302Sopenharmony_ci time_t is = new->it_interval.tv_sec, vs = new->it_value.tv_sec; 12570af302Sopenharmony_ci long ius = new->it_interval.tv_usec, vus = new->it_value.tv_usec; 13570af302Sopenharmony_ci if (!IS32BIT(is) || !IS32BIT(vs)) 14570af302Sopenharmony_ci return __syscall_ret(-ENOTSUP); 15570af302Sopenharmony_ci long old32[4]; 16570af302Sopenharmony_ci int r = __syscall(SYS_setitimer, which, 17570af302Sopenharmony_ci ((long[]){is, ius, vs, vus}), old32); 18570af302Sopenharmony_ci if (!r && old) { 19570af302Sopenharmony_ci old->it_interval.tv_sec = old32[0]; 20570af302Sopenharmony_ci old->it_interval.tv_usec = old32[1]; 21570af302Sopenharmony_ci old->it_value.tv_sec = old32[2]; 22570af302Sopenharmony_ci old->it_value.tv_usec = old32[3]; 23570af302Sopenharmony_ci } 24570af302Sopenharmony_ci return __syscall_ret(r); 25570af302Sopenharmony_ci } 26570af302Sopenharmony_ci#endif 27570af302Sopenharmony_ci return syscall(SYS_setitimer, which, new, old); 28570af302Sopenharmony_ci} 29