Added new function time_get_os_boottime_us() and unit tests
Also, re-implement existing function time_get_os_boottime_ms()
by using the new function time_get_os_boottime_us()
Change-Id: I5c6ba3d04b04c96e0a415b2be1050ef05cb04585
diff --git a/osi/src/time.c b/osi/src/time.c
index f1d8dca..c432a28 100644
--- a/osi/src/time.c
+++ b/osi/src/time.c
@@ -23,7 +23,13 @@
#include "osi/include/time.h"
uint32_t time_get_os_boottime_ms(void) {
- struct timespec timespec;
- clock_gettime(CLOCK_BOOTTIME, ×pec);
- return (timespec.tv_sec * 1000) + (timespec.tv_nsec / 1000000);
+ return (uint32_t) (time_get_os_boottime_us() / 1000);
+}
+
+uint64_t time_get_os_boottime_us(void) {
+ struct timespec ts_now;
+ clock_gettime(CLOCK_BOOTTIME, &ts_now);
+
+ return ((uint64_t)ts_now.tv_sec * 1000000L) +
+ ((uint64_t)ts_now.tv_nsec / 1000);
}