1 #define _BSD_SOURCE 2 #include <sys/time.h> 3 #include <time.h> 4 #include <errno.h> 5 #include "syscall.h" 6 settimeofday(const struct timeval * tv,const struct timezone * tz)7int settimeofday(const struct timeval *tv, const struct timezone *tz) 8 { 9 #ifndef __LITEOS__ 10 return syscall(SYS_settimeofday, tv, tz); 11 #else 12 if (!tv) return 0; 13 if (tv->tv_usec >= 1000000ULL) return __syscall_ret(-EINVAL); 14 return clock_settime(CLOCK_REALTIME, &((struct timespec){ 15 .tv_sec = tv->tv_sec, .tv_nsec = tv->tv_usec * 1000})); 16 #endif 17 } 18