Selaa lähdekoodia

as of POSIX.1-2008 gettimeofday() is obsolete

Steffen Jaeckel 7 vuotta sitten
vanhempi
commit
35c4d157d0
1 muutettua tiedostoa jossa 3 lisäystä ja 3 poistoa
  1. 3 3
      tests/test.c

+ 3 - 3
tests/test.c

@@ -72,9 +72,9 @@ static ulong64 epoch_usec(void)
   cur_time /= 10; /* nanoseconds > microseconds */
   return cur_time;
 #else
-  struct timeval tv;
-  gettimeofday(&tv, NULL);
-  return (ulong64)(tv.tv_sec) * 1000000 + (ulong64)(tv.tv_usec); /* get microseconds */
+  struct timespec ts;
+  clock_gettime(CLOCK_MONOTONIC, &ts);
+  return (ulong64)(ts.tv_sec) * 1000000 + (ulong64)(ts.tv_nsec) / 1000; /* get microseconds */
 #endif
 }