]> granicus.if.org Git - esp-idf/commitdiff
newlib: Move _gettimeofday_r call in clock_gettime
authorraldone01 <raldone01@gmail.com>
Tue, 16 Jul 2019 15:52:04 +0000 (17:52 +0200)
committerKonstantinKondrashov <konstantin@espressif.com>
Wed, 7 Aug 2019 12:37:11 +0000 (20:37 +0800)
Signed-off-by: KonstantinKondrashov <konstantin@espressif.com>
Merges: https://github.com/espressif/esp-idf/pull/3789

components/newlib/time.c

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