base: chrono_utils: supported in linux

Tried to use this on host executable, and it always read back zero
for duration.  Expanded code to support any linux build.

Test: works on host
Bug: 38446744
Bug: 66912053
Change-Id: I4a2cbbfff3e7739b54cb6c6e877898de4d3d2296
This commit is contained in:
Mark Salyzyn 2017-10-03 12:50:00 -07:00
parent 541428a13b
commit 1f9fa7e907

View file

@ -22,7 +22,7 @@ namespace android {
namespace base {
boot_clock::time_point boot_clock::now() {
#ifdef __ANDROID__
#ifdef __linux__
timespec ts;
clock_gettime(CLOCK_BOOTTIME, &ts);
return boot_clock::time_point(std::chrono::seconds(ts.tv_sec) +
@ -30,7 +30,7 @@ boot_clock::time_point boot_clock::now() {
#else
// Darwin does not support clock_gettime.
return boot_clock::time_point();
#endif // __ANDROID__
#endif // __linux__
}
std::ostream& operator<<(std::ostream& os, const Timer& t) {