mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
fix System.currentTimeMillis on Windows
This commit is contained in:
parent
86a5e9ba8a
commit
575df206cd
@ -27,6 +27,8 @@
|
|||||||
# include "winbase.h"
|
# include "winbase.h"
|
||||||
# include "io.h"
|
# include "io.h"
|
||||||
# include "tchar.h"
|
# include "tchar.h"
|
||||||
|
# include "sys/types.h"
|
||||||
|
# include "sys/timeb.h"
|
||||||
# define SO_PREFIX ""
|
# define SO_PREFIX ""
|
||||||
#else
|
#else
|
||||||
# define SO_PREFIX "lib"
|
# define SO_PREFIX "lib"
|
||||||
@ -388,24 +390,9 @@ extern "C" JNIEXPORT jlong JNICALL
|
|||||||
Java_java_lang_System_currentTimeMillis(JNIEnv*, jclass)
|
Java_java_lang_System_currentTimeMillis(JNIEnv*, jclass)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
static LARGE_INTEGER frequency;
|
_timeb tb;
|
||||||
static LARGE_INTEGER time;
|
_ftime(&tb);
|
||||||
static bool init = true;
|
return (static_cast<jlong>(tb.time) * 1000) + static_cast<jlong>(tb.millitm);
|
||||||
|
|
||||||
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)));
|
|
||||||
#else
|
#else
|
||||||
timeval tv = { 0, 0 };
|
timeval tv = { 0, 0 };
|
||||||
gettimeofday(&tv, 0);
|
gettimeofday(&tv, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user