fix windows.cpp MySystem::now

This commit is contained in:
Joel Dice 2010-11-07 12:35:31 -07:00
parent 6cf3666ed9
commit 75de0a621b
2 changed files with 8 additions and 19 deletions

View File

@ -769,24 +769,13 @@ class MySystem: public System {
}
virtual int64_t now() {
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<int64_t>
(((static_cast<double>(time.QuadPart)) * 1000.0) /
(static_cast<double>(frequency.QuadPart)));
// 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<int64_t>(time.dwHighDateTime) << 32)
| time.dwLowDateTime) / 10000) - 11644473600000LL;
}
virtual void exit(int code) {

View File

@ -205,6 +205,6 @@ public class Misc {
}
}
System.out.println(java.util.Calendar.getInstance().toString());
System.out.println(new java.util.Date().toString());
}
}