Avoid overflow when calculating multiplying performance counter

This commit is contained in:
Alcaro 2020-02-28 18:07:00 +01:00 committed by GitHub
parent a10db7c280
commit 472fe9a991
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -225,7 +225,7 @@ retro_time_t cpu_features_get_time_usec(void)
if (!QueryPerformanceCounter(&count))
return 0;
return count.QuadPart * 1000000 / freq.QuadPart;
return (count.QuadPart / freq.QuadPart * 1000000) + (count.QuadPart % freq.QuadPart * 1000000 / freq.QuadPart);
#elif defined(__CELLOS_LV2__)
return sys_time_get_system_time();
#elif defined(GEKKO)