Merge "fastboot: Use clock_gettime(CLOCK_MONOTONIC) in now()" into main am: 2d686d7b71
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2955185
Change-Id: Ie3c5ca7f532f92c77ebc7df8eedf3748a3f478cf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/fastboot/util.cpp b/fastboot/util.cpp
index e03012a..5966aea 100644
--- a/fastboot/util.cpp
+++ b/fastboot/util.cpp
@@ -31,7 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
-#include <sys/time.h>
+#include <time.h>
#include <android-base/parseint.h>
#include <android-base/strings.h>
@@ -43,9 +43,9 @@
static bool g_verbose = false;
double now() {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return (double)tv.tv_sec + (double)tv.tv_usec / 1000000;
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return (double)ts.tv_sec + (double)ts.tv_nsec / 1000000000;
}
void die(const char* fmt, ...) {