summaryrefslogtreecommitdiffstats
path: root/luni
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-06-20 23:37:02 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-06-20 23:37:02 +0000
commit7bd5cc7f252dc16ab434cb1440abe5152e28f9c1 (patch)
tree0872ee5eabcaa40e0a4a5f25b1fc8f72611fd10c /luni
parent20bbe6cc4f3974bb038aa035bcebd205fc9171e8 (diff)
parent7757924895a28a43ab9f7c3931cc9f972e870ddc (diff)
downloadlibcore-7bd5cc7f252dc16ab434cb1440abe5152e28f9c1.zip
libcore-7bd5cc7f252dc16ab434cb1440abe5152e28f9c1.tar.gz
libcore-7bd5cc7f252dc16ab434cb1440abe5152e28f9c1.tar.bz2
Merge "Use CLOCK_MONOTONIC_RAW for System.nanoTime."
Diffstat (limited to 'luni')
-rw-r--r--luni/src/main/java/java/lang/System.java3
-rw-r--r--luni/src/main/native/java_lang_System.cpp6
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;
}