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);