From 575df206cd1f34637c98b8d1f0a7f09e46e955e2 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 17 Jun 2008 09:05:57 -0600 Subject: [PATCH] fix System.currentTimeMillis on Windows --- classpath/java-lang.cpp | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/classpath/java-lang.cpp b/classpath/java-lang.cpp index 967deaadb4..5fd06cc8fe 100644 --- a/classpath/java-lang.cpp +++ b/classpath/java-lang.cpp @@ -27,6 +27,8 @@ # include "winbase.h" # include "io.h" # include "tchar.h" +# include "sys/types.h" +# include "sys/timeb.h" # define SO_PREFIX "" #else # define SO_PREFIX "lib" @@ -388,24 +390,9 @@ extern "C" JNIEXPORT jlong JNICALL Java_java_lang_System_currentTimeMillis(JNIEnv*, jclass) { #ifdef WIN32 - static LARGE_INTEGER frequency; - static LARGE_INTEGER time; - static bool init = true; - - if (init) { - QueryPerformanceFrequency(&frequency); - - if (frequency.QuadPart == 0) { - return 0; - } - - init = false; - } - - QueryPerformanceCounter(&time); - return static_cast - (((static_cast(time.QuadPart)) * 1000.0) / - (static_cast(frequency.QuadPart))); + _timeb tb; + _ftime(&tb); + return (static_cast(tb.time) * 1000) + static_cast(tb.millitm); #else timeval tv = { 0, 0 }; gettimeofday(&tv, 0);