diff options
-rw-r--r-- | luni/src/main/java/java/lang/System.java | 3 | ||||
-rw-r--r-- | luni/src/main/native/java_lang_System.cpp | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/luni/src/main/java/java/lang/System.java b/luni/src/main/java/java/lang/System.java index c825118..46aed59 100644 --- a/luni/src/main/java/java/lang/System.java +++ b/luni/src/main/java/java/lang/System.java @@ -170,7 +170,8 @@ public final class System { /** * Returns the current timestamp of the most precise timer available on the - * local system, in nanoseconds. Equivalent to Linux's {@code CLOCK_MONOTONIC}. + * local system, in nanoseconds. Equivalent to something like Linux's + * {@code CLOCK_MONOTONIC_RAW}. * * <p>This timestamp should only be used to measure a duration by comparing it * against another timestamp from the same process on the same device. diff --git a/luni/src/main/native/java_lang_System.cpp b/luni/src/main/native/java_lang_System.cpp index 0686310..2c48309 100644 --- a/luni/src/main/native/java_lang_System.cpp +++ b/luni/src/main/native/java_lang_System.cpp @@ -94,7 +94,11 @@ static jlong System_currentTimeMillis(JNIEnv*, jclass) { static jlong System_nanoTime(JNIEnv*, jclass) { timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); +#ifdef CLOCK_MONOTONIC_RAW + clock_gettime(CLOCK_MONOTONIC_RAW, &now); +#else // Darwin, say. + clock_gettime(CLOCK_MONOTONIC, &now); +#endif return now.tv_sec * 1000000000LL + now.tv_nsec; } |