Procházet zdrojové kódy

Merge branch 'feature/move_gettimeofday_in_clock_gettime' into 'master'

newlib: Move _gettimeofday_r call in clock_gettime

Closes IDFGH-1525

See merge request espressif/esp-idf!5562
Angus Gratton před 6 roky
rodič
revize
e9b77d3a69
1 změnil soubory, kde provedl 1 přidání a 1 odebrání
  1. 1 1
      components/newlib/time.c

+ 1 - 1
components/newlib/time.c

@@ -414,10 +414,10 @@ int clock_gettime (clockid_t clock_id, struct timespec *tp)
         return -1;
         return -1;
     }
     }
     struct timeval tv;
     struct timeval tv;
-    _gettimeofday_r(NULL, &tv, NULL);
     uint64_t monotonic_time_us = 0;
     uint64_t monotonic_time_us = 0;
     switch (clock_id) {
     switch (clock_id) {
         case CLOCK_REALTIME:
         case CLOCK_REALTIME:
+            _gettimeofday_r(NULL, &tv, NULL);
             tp->tv_sec = tv.tv_sec;
             tp->tv_sec = tv.tv_sec;
             tp->tv_nsec = tv.tv_usec * 1000L;
             tp->tv_nsec = tv.tv_usec * 1000L;
             break;
             break;