From 5ade8d1cf65cf62adc6d8f85072967060f4659fc Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 28 Oct 2010 20:30:49 -0600 Subject: [PATCH] use GetSystemTimeAsFileTime instead of _ftime on Windows It seems that _ftime has devolved to only giving 1-second resolution on Windows 7. GetSystemTimeAsFileTime does better, so that's what we'll use. --- classpath/java-lang.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/classpath/java-lang.cpp b/classpath/java-lang.cpp index 9331ee099f..ea37b2f275 100644 --- a/classpath/java-lang.cpp +++ b/classpath/java-lang.cpp @@ -36,9 +36,6 @@ # define isnan _isnan # define isfinite _finite # define strtof strtod -# define FTIME _ftime_s -# else -# define FTIME _ftime # endif #else // not PLATFORM_WINDOWS @@ -469,9 +466,13 @@ extern "C" JNIEXPORT jlong JNICALL Java_java_lang_System_currentTimeMillis(JNIEnv*, jclass) { #ifdef PLATFORM_WINDOWS - _timeb tb; - FTIME(&tb); - return (static_cast(tb.time) * 1000) + static_cast(tb.millitm); + // We used to use _ftime here, but that only gives us 1-second + // resolution on Windows 7. _ftime_s might work better, but MinGW + // doesn't have it as of this writing. So we use this mess instead: + FILETIME time; + GetSystemTimeAsFileTime(&time); + return (((static_cast(time.dwHighDateTime) << 32) + | time.dwLowDateTime) / 10000) - 11644473600000LL; #else timeval tv = { 0, 0 }; gettimeofday(&tv, 0);