Parcourir la source

update hl_sys_time on Windows (#281)

close #280
Constantine Teplyakov il y a 6 ans
Parent
commit
a02522b132
1 fichiers modifiés avec 6 ajouts et 2 suppressions
  1. 6 2
      src/std/sys.c

+ 6 - 2
src/std/sys.c

@@ -163,14 +163,18 @@ HL_PRIM void hl_sys_exit( int code ) {
 
 HL_PRIM double hl_sys_time() {
 #ifdef HL_WIN
+	#define EPOCH_DIFF	(134774*24*60*60.0)
 	static double freq = 0.;
 	LARGE_INTEGER time;
+	FILETIME ft;
 	if( freq == 0 ) {
 		QueryPerformanceFrequency(&time);
 		freq = (double)time.QuadPart;
 	}
-	QueryPerformanceCounter(&time);
-	return ((double)time.QuadPart) / freq;
+	GetSystemTimePreciseAsFileTime(&ft);
+	time.LowPart = ft.dwLowDateTime;
+	time.HighPart = ft.dwHighDateTime;
+	return ((double)time.QuadPart) / freq - EPOCH_DIFF;
 #else
 	struct timeval tv;
 	if( gettimeofday(&tv,NULL) != 0 )