Fix timeGetTime on Linux

This commit is contained in:
Alexander Batalov 2022-06-02 21:11:23 +03:00
parent 2e7070a942
commit 0819937e56
1 changed files with 4 additions and 4 deletions

View File

@ -21,7 +21,7 @@
#ifdef _WIN32 #ifdef _WIN32
#include <timeapi.h> #include <timeapi.h>
#else #else
#include <sys/time.h> #include <chrono>
#endif #endif
int compat_stricmp(const char* string1, const char* string2) int compat_stricmp(const char* string1, const char* string2)
@ -145,8 +145,8 @@ unsigned int compat_timeGetTime()
#ifdef _WIN32 #ifdef _WIN32
return timeGetTime(); return timeGetTime();
#else #else
struct timeval tv; static auto start = std::chrono::steady_clock::now();
gettimeofday(&tv, NULL); auto now = std::chrono::steady_clock::now();
return tv.tv_usec / 1000; return static_cast<unsigned int>(std::chrono::duration_cast<std::chrono::milliseconds>(now - start).count());
#endif #endif
} }