diff options
author | Tom Tromey <tromey@redhat.com> | 2006-03-09 18:47:54 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2006-03-09 18:47:54 +0000 |
commit | e59a1e40f318e53c11a069140e4380ca05dd75cd (patch) | |
tree | 744b26f2524a58c1a0d12f1c85353fc349623374 /libjava/posix.cc | |
parent | cbbb5b6da1a7ac6efd97d97cda4cbd4868c56eaf (diff) | |
download | gcc-e59a1e40f318e53c11a069140e4380ca05dd75cd.tar.gz |
win32.cc (_Jv_platform_nanotime): New function.
* win32.cc (_Jv_platform_nanotime): New function.
* include/win32.h (_Jv_platform_nanotime): Declare.
* posix.cc (_Jv_platform_nanotime): New function.
* include/posix.h (_Jv_platform_nanotime): Declare.
* java/lang/natSystem.cc (nanoTime): New method.
* java/lang/System.java (nanoTime): Declare.
* include/config.h.in, configure: Rebuilt.
* configure.ac: Check for clock_gettime.
From-SVN: r111869
Diffstat (limited to 'libjava/posix.cc')
-rw-r--r-- | libjava/posix.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/libjava/posix.cc b/libjava/posix.cc index 3b551966fca..15fc9c5c3f8 100644 --- a/libjava/posix.cc +++ b/libjava/posix.cc @@ -1,6 +1,6 @@ // posix.cc -- Helper functions for POSIX-flavored OSs. -/* Copyright (C) 2000, 2001, 2002 Free Software Foundation +/* Copyright (C) 2000, 2001, 2002, 2006 Free Software Foundation This file is part of libgcj. @@ -66,6 +66,22 @@ _Jv_platform_gettimeofday () #endif } +jlong +_Jv_platform_nanotime () +{ +#ifdef HAVE_CLOCK_GETTIME + struct timespec now; + if (clock_gettime (CLOCK_REALTIME, &now) == 0) + { + jlong result = (jlong) now.tv_sec; + result = result * 1000 * 1000 + now.tv_nsec; + return result; + } + // clock_gettime failed, but we can fall through. +#endif // HAVE_CLOCK_GETTIME + return _Jv_platform_gettimeofday () * 1000LL; +} + // Platform-specific VM initialization. void _Jv_platform_initialize (void) |