summaryrefslogtreecommitdiff
path: root/libjava/posix.cc
diff options
context:
space:
mode:
authorgeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2006-09-14 01:17:31 +0000
committergeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2006-09-14 01:17:31 +0000
commit0bb92388895783dad3b13b8deb9d182bbedc5408 (patch)
treea5280d81d511353d5613e3482a10f15f1a24c4c1 /libjava/posix.cc
parent09fa572c45232c54bebd4f301df52f0112828ce4 (diff)
downloadgcc-0bb92388895783dad3b13b8deb9d182bbedc5408.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116941 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/posix.cc')
-rw-r--r--libjava/posix.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/libjava/posix.cc b/libjava/posix.cc
index d191d8ea7a1..df798b88a2b 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.