diff options
author | Greg Hackmann <ghackmann@google.com> | 2013-12-18 00:26:07 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-12-18 00:26:07 +0000 |
commit | 7510fa3e71e3d42065de44ccf3e0fa50606ecf05 (patch) | |
tree | 37806b29a2c44c4d4e251e5b2ab2823a8b2e901f | |
parent | c042bb01df9046a4aa7afeefe6d9b14a5bbc2ca2 (diff) | |
parent | d38ca369c07744abeb5477c6a524a683fb9a4927 (diff) | |
download | system_core-7510fa3e71e3d42065de44ccf3e0fa50606ecf05.zip system_core-7510fa3e71e3d42065de44ccf3e0fa50606ecf05.tar.gz system_core-7510fa3e71e3d42065de44ccf3e0fa50606ecf05.tar.bz2 |
am d38ca369: am 9ade11c1: Merge "SystemClock: use clock_gettime() on devices without /dev/alarm"
* commit 'd38ca369c07744abeb5477c6a524a683fb9a4927':
SystemClock: use clock_gettime() on devices without /dev/alarm
-rw-r--r-- | libutils/SystemClock.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/libutils/SystemClock.cpp b/libutils/SystemClock.cpp index ac8da88..413250f 100644 --- a/libutils/SystemClock.cpp +++ b/libutils/SystemClock.cpp @@ -119,22 +119,6 @@ int64_t elapsedRealtimeNano() static volatile int prevMethod; #endif -#if 0 - /* - * b/7100774 - * clock_gettime appears to have clock skews and can sometimes return - * backwards values. Disable its use until we find out what's wrong. - */ - result = clock_gettime(CLOCK_BOOTTIME, &ts); - if (result == 0) { - timestamp = seconds_to_nanoseconds(ts.tv_sec) + ts.tv_nsec; - checkTimeStamps(timestamp, &prevTimestamp, &prevMethod, - METHOD_CLOCK_GETTIME); - return timestamp; - } -#endif - - // CLOCK_BOOTTIME doesn't exist, fallback to /dev/alarm static int s_fd = -1; if (s_fd == -1) { @@ -153,6 +137,15 @@ int64_t elapsedRealtimeNano() return timestamp; } + // /dev/alarm doesn't exist, fallback to CLOCK_BOOTTIME + result = clock_gettime(CLOCK_BOOTTIME, &ts); + if (result == 0) { + timestamp = seconds_to_nanoseconds(ts.tv_sec) + ts.tv_nsec; + checkTimeStamps(timestamp, &prevTimestamp, &prevMethod, + METHOD_CLOCK_GETTIME); + return timestamp; + } + // XXX: there was an error, probably because the driver didn't // exist ... this should return // a real error, like an exception! |