mirror of https://github.com/axmolengine/axmol.git
fixed #1017: improve win32 timing accuracy
This commit is contained in:
parent
74b4b14ee3
commit
a0f0971782
|
@ -30,20 +30,11 @@ int CC_DLL gettimeofday(struct timeval * val, struct timezone *)
|
||||||
{
|
{
|
||||||
if (val)
|
if (val)
|
||||||
{
|
{
|
||||||
SYSTEMTIME wtm;
|
LARGE_INTEGER liTime, liFreq;
|
||||||
GetLocalTime(&wtm);
|
QueryPerformanceFrequency( &liFreq );
|
||||||
|
QueryPerformanceCounter( &liTime );
|
||||||
struct tm tTm;
|
val->tv_sec = (long)( liTime.QuadPart / liFreq.QuadPart );
|
||||||
tTm.tm_year = wtm.wYear - 1900;
|
val->tv_usec = (long)( liTime.QuadPart * 1000000.0 / liFreq.QuadPart - val->tv_sec * 1000000.0 );
|
||||||
tTm.tm_mon = wtm.wMonth - 1;
|
|
||||||
tTm.tm_mday = wtm.wDay;
|
|
||||||
tTm.tm_hour = wtm.wHour;
|
|
||||||
tTm.tm_min = wtm.wMinute;
|
|
||||||
tTm.tm_sec = wtm.wSecond;
|
|
||||||
tTm.tm_isdst = -1;
|
|
||||||
|
|
||||||
val->tv_sec = (long)mktime(&tTm); // time_t is 64-bit on win32
|
|
||||||
val->tv_usec = wtm.wMilliseconds * 1000;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue