bootstat: Refactor init/utils/boot_clock into base/chrono_utils.
Use this for bootstat and init. This replaces the custom uptime parser in
bootstat.
This is a reland of aosp/338325 with a stubbed implementation for Darwin.
This change also has clang_format fixes (automatic).
Bug: 34352037
Test: chrono_utils_test
Change-Id: I72a62a3ca1ccfc0a4ccc6294ff1776c263144686
diff --git a/init/util.cpp b/init/util.cpp
index 8a19939..14fd7ab 100644
--- a/init/util.cpp
+++ b/init/util.cpp
@@ -52,6 +52,8 @@
#include "reboot.h"
#include "util.h"
+using android::base::boot_clock;
+
static unsigned int do_decode_uid(const char *s)
{
unsigned int v;
@@ -198,13 +200,6 @@
return success;
}
-boot_clock::time_point boot_clock::now() {
- timespec ts;
- clock_gettime(CLOCK_BOOTTIME, &ts);
- return boot_clock::time_point(std::chrono::seconds(ts.tv_sec) +
- std::chrono::nanoseconds(ts.tv_nsec));
-}
-
int mkdir_recursive(const char *pathname, mode_t mode)
{
char buf[128];