This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: FYI: System.nanoTime
- From: Tom Tromey <tromey at redhat dot com>
- To: Cédric Berger <cedric at berger dot to>
- Cc: java-patches at gcc dot gnu dot org
- Date: 28 Mar 2006 12:12:38 -0700
- Subject: Re: Patch: FYI: System.nanoTime
- References: <44113723.6030706@berger.to>
- Reply-to: tromey at redhat dot com
>>>>> "Cédric" == Cédric Berger <cedric@berger.to> writes:
Cédric> Why do you use CLOCK_REALTIME? it represents the time
Cédric> from the epoch, but nanoTime() javadoc atate that
Cédric> nanoTime() value should be used for measuring elapsed
Cédric> time and is unrelated to wall-clock time.
What do you think of the appended?
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* posix.cc (_Jv_platform_nanotime): Look for CLOCK_MONOTONIC and
CLOCK_HIGHRES.
Index: posix.cc
===================================================================
--- posix.cc (revision 112466)
+++ posix.cc (working copy)
@@ -71,7 +71,15 @@
{
#ifdef HAVE_CLOCK_GETTIME
struct timespec now;
- if (clock_gettime (CLOCK_REALTIME, &now) == 0)
+ int id;
+#ifdef CLOCK_MONOTONIC
+ id = CLOCK_MONOTONIC;
+#elif defined (CLOCK_HIGHRES)
+ id = CLOCK_HIGHRES;
+#else
+ id = CLOCK_REALTIME;
+#endif
+ if (clock_gettime (id, &now) == 0)
{
jlong result = (jlong) now.tv_sec;
result = result * 1000 * 1000 + now.tv_nsec;