diff options
author | Geoffrey Keating <geoffk@apple.com> | 2006-09-14 01:17:31 +0000 |
---|---|---|
committer | Geoffrey Keating <geoffk@gcc.gnu.org> | 2006-09-14 01:17:31 +0000 |
commit | 06fcf75439fbafae348fa33a0630f7bd83a835aa (patch) | |
tree | a5280d81d511353d5613e3482a10f15f1a24c4c1 /libjava/posix.cc | |
parent | f5efb27f743ce6bab0fe4f33a9573313e24dacdb (diff) | |
download | gcc-06fcf75439fbafae348fa33a0630f7bd83a835aa.zip gcc-06fcf75439fbafae348fa33a0630f7bd83a835aa.tar.gz gcc-06fcf75439fbafae348fa33a0630f7bd83a835aa.tar.bz2 |
posix.cc (_Jv_platform_nanotime): Return nanoseconds, not microseconds; use gettimeofday when available.
* posix.cc (_Jv_platform_nanotime): Return nanoseconds, not
microseconds; use gettimeofday when available.
* posix-threads.cc (_Jv_CondWait): Improve accuracy and range of
timeout calculation.
* testsuite/libjava.lang/Thread_Sleep_2.java: New.
* testsuite/libjava.lang/Thread_Sleep_2.out: New.
* testsuite/libjava.lang/Thread_Sleep_2.xfail: New.
From-SVN: r116941
Diffstat (limited to 'libjava/posix.cc')
-rw-r--r-- | libjava/posix.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libjava/posix.cc b/libjava/posix.cc index d191d8e..df798b8 100644 --- a/libjava/posix.cc +++ b/libjava/posix.cc @@ -87,12 +87,20 @@ _Jv_platform_nanotime () if (clock_gettime (id, &now) == 0) { jlong result = (jlong) now.tv_sec; - result = result * 1000 * 1000 + now.tv_nsec; + result = result * 1000000000LL + now.tv_nsec; return result; } // clock_gettime failed, but we can fall through. #endif // HAVE_CLOCK_GETTIME - return _Jv_platform_gettimeofday () * 1000LL; +#if defined (HAVE_GETTIMEOFDAY) + { + timeval tv; + gettimeofday (&tv, NULL); + return (tv.tv_sec * 1000000000LL) + tv.tv_usec * 1000LL; + } +#else + return _Jv_platform_gettimeofday () * 1000000LL; +#endif } // Platform-specific VM initialization. |