summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Gao2017-04-28 14:39:48 -0500
committerJosh Gao2017-04-28 15:00:00 -0500
commitae29339ca138648eeaee68f801feb02d85ee2abf (patch)
treefae72a160e4812f326207e25b40a167980d649fd /base/chrono_utils.cpp
parent263e1e95093b9f66b7d62cbd622e09b6a8b9252f (diff)
downloadplatform-system-core-ae29339ca138648eeaee68f801feb02d85ee2abf.tar.gz
platform-system-core-ae29339ca138648eeaee68f801feb02d85ee2abf.tar.xz
platform-system-core-ae29339ca138648eeaee68f801feb02d85ee2abf.zip
base: make boot_clock work on host linux, hide it on non-linux.
boot_clock was previously returning zero on any platform that doesn't define __ANDROID__, including host bionic. Instead of returning a bogus value, just hide it on non-Linux platforms. Bug: http://b/37758947 Test: libbase_test32/64 on linux Change-Id: I96e1d8b92dc44c6308408900cf0d27e1e7db5569
Diffstat (limited to 'base/chrono_utils.cpp')
-rw-r--r--base/chrono_utils.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/base/chrono_utils.cpp b/base/chrono_utils.cpp
index 5eedf3bce..d73b551b5 100644
--- a/base/chrono_utils.cpp
+++ b/base/chrono_utils.cpp
@@ -21,17 +21,14 @@
21namespace android { 21namespace android {
22namespace base { 22namespace base {
23 23
24#if defined(__linux__)
24boot_clock::time_point boot_clock::now() { 25boot_clock::time_point boot_clock::now() {
25#ifdef __ANDROID__
26 timespec ts; 26 timespec ts;
27 clock_gettime(CLOCK_BOOTTIME, &ts); 27 clock_gettime(CLOCK_BOOTTIME, &ts);
28 return boot_clock::time_point(std::chrono::seconds(ts.tv_sec) + 28 return boot_clock::time_point(std::chrono::seconds(ts.tv_sec) +
29 std::chrono::nanoseconds(ts.tv_nsec)); 29 std::chrono::nanoseconds(ts.tv_nsec));
30#else
31 // Darwin does not support clock_gettime.
32 return boot_clock::time_point();
33#endif // __ANDROID__
34} 30}
31#endif
35 32
36} // namespace base 33} // namespace base
37} // namespace android 34} // namespace android