Loading base/Android.bp +4 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,6 @@ cc_library { clang: true, host_supported: true, srcs: [ "chrono_utils.cpp", "file.cpp", "logging.cpp", "parsenetaddress.cpp", Loading @@ -65,6 +64,7 @@ cc_library { srcs: [ "errors_unix.cpp", "properties.cpp", "chrono_utils.cpp", ], cppflags: ["-Wexit-time-destructors"], sanitize: { Loading @@ -74,12 +74,14 @@ cc_library { }, darwin: { srcs: [ "chrono_utils.cpp", "errors_unix.cpp", ], cppflags: ["-Wexit-time-destructors"], }, linux_bionic: { srcs: [ "chrono_utils.cpp", "errors_unix.cpp", ], cppflags: ["-Wexit-time-destructors"], Loading @@ -87,6 +89,7 @@ cc_library { }, linux: { srcs: [ "chrono_utils.cpp", "errors_unix.cpp", ], cppflags: ["-Wexit-time-destructors"], Loading base/chrono_utils.cpp +5 −2 Original line number Diff line number Diff line Loading @@ -21,14 +21,17 @@ namespace android { namespace base { #if defined(__linux__) boot_clock::time_point boot_clock::now() { #ifdef __ANDROID__ timespec ts; clock_gettime(CLOCK_BOOTTIME, &ts); return boot_clock::time_point(std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec)); #else // Darwin does not support clock_gettime. return boot_clock::time_point(); #endif // __ANDROID__ } #endif } // namespace base } // namespace android base/chrono_utils_test.cpp +2 −7 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ #include "android-base/chrono_utils.h" #include <err.h> #include <time.h> #include <chrono> Loading @@ -26,12 +25,9 @@ namespace android { namespace base { #if defined(__linux__) std::chrono::seconds GetBootTimeSeconds() { struct timespec now; if (clock_gettime(CLOCK_BOOTTIME, &now) != 0) { err(1, "clock_gettime failed"); } clock_gettime(CLOCK_BOOTTIME, &now); auto now_tp = boot_clock::time_point(std::chrono::seconds(now.tv_sec) + std::chrono::nanoseconds(now.tv_nsec)); Loading @@ -45,7 +41,6 @@ TEST(ChronoUtilsTest, BootClockNowSeconds) { std::chrono::duration_cast<std::chrono::seconds>(boot_clock::now().time_since_epoch()); EXPECT_EQ(now, boot_seconds); } #endif // defined(__linux__) } // namespace base } // namespace android No newline at end of file base/include/android-base/chrono_utils.h +0 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ namespace android { namespace base { #if defined(__linux__) // A std::chrono clock based on CLOCK_BOOTTIME. class boot_clock { public: Loading @@ -31,7 +30,6 @@ class boot_clock { static time_point now(); }; #endif // defined(__linux__) } // namespace base } // namespace android Loading Loading
base/Android.bp +4 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,6 @@ cc_library { clang: true, host_supported: true, srcs: [ "chrono_utils.cpp", "file.cpp", "logging.cpp", "parsenetaddress.cpp", Loading @@ -65,6 +64,7 @@ cc_library { srcs: [ "errors_unix.cpp", "properties.cpp", "chrono_utils.cpp", ], cppflags: ["-Wexit-time-destructors"], sanitize: { Loading @@ -74,12 +74,14 @@ cc_library { }, darwin: { srcs: [ "chrono_utils.cpp", "errors_unix.cpp", ], cppflags: ["-Wexit-time-destructors"], }, linux_bionic: { srcs: [ "chrono_utils.cpp", "errors_unix.cpp", ], cppflags: ["-Wexit-time-destructors"], Loading @@ -87,6 +89,7 @@ cc_library { }, linux: { srcs: [ "chrono_utils.cpp", "errors_unix.cpp", ], cppflags: ["-Wexit-time-destructors"], Loading
base/chrono_utils.cpp +5 −2 Original line number Diff line number Diff line Loading @@ -21,14 +21,17 @@ namespace android { namespace base { #if defined(__linux__) boot_clock::time_point boot_clock::now() { #ifdef __ANDROID__ timespec ts; clock_gettime(CLOCK_BOOTTIME, &ts); return boot_clock::time_point(std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec)); #else // Darwin does not support clock_gettime. return boot_clock::time_point(); #endif // __ANDROID__ } #endif } // namespace base } // namespace android
base/chrono_utils_test.cpp +2 −7 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ #include "android-base/chrono_utils.h" #include <err.h> #include <time.h> #include <chrono> Loading @@ -26,12 +25,9 @@ namespace android { namespace base { #if defined(__linux__) std::chrono::seconds GetBootTimeSeconds() { struct timespec now; if (clock_gettime(CLOCK_BOOTTIME, &now) != 0) { err(1, "clock_gettime failed"); } clock_gettime(CLOCK_BOOTTIME, &now); auto now_tp = boot_clock::time_point(std::chrono::seconds(now.tv_sec) + std::chrono::nanoseconds(now.tv_nsec)); Loading @@ -45,7 +41,6 @@ TEST(ChronoUtilsTest, BootClockNowSeconds) { std::chrono::duration_cast<std::chrono::seconds>(boot_clock::now().time_since_epoch()); EXPECT_EQ(now, boot_seconds); } #endif // defined(__linux__) } // namespace base } // namespace android No newline at end of file
base/include/android-base/chrono_utils.h +0 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ namespace android { namespace base { #if defined(__linux__) // A std::chrono clock based on CLOCK_BOOTTIME. class boot_clock { public: Loading @@ -31,7 +30,6 @@ class boot_clock { static time_point now(); }; #endif // defined(__linux__) } // namespace base } // namespace android Loading