gettimeofday.c 266 B

12345678910111213
  1. #include <time.h>
  2. #include <sys/time.h>
  3. #include "syscall.h"
  4. int gettimeofday(struct timeval *tv, void *tz)
  5. {
  6. struct timespec ts;
  7. if (!tv) return 0;
  8. clock_gettime(CLOCK_REALTIME, &ts);
  9. tv->tv_sec = ts.tv_sec;
  10. tv->tv_usec = (int)ts.tv_nsec / 1000;
  11. return 0;
  12. }