Misc. Linux improvements and bug fixes. (#121)

Co-authored-by: Tom Lally <tomlally@protonmail.com>
This commit is contained in:
Tom Lally 2022-09-01 19:46:20 +01:00 committed by GitHub
parent b8d4cf5b29
commit d3a7b3b5a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 101 additions and 104 deletions

View file

@ -32,7 +32,7 @@ uint64 muldiv64(uint64 a, uint64 b, uint64 d)
bool PPCTimer_hasInvariantRDTSCSupport()
{
uint32 cpuv[4];
__cpuid((int*)cpuv, 0x80000007);
cpuid((int*)cpuv, 0x80000007);
return ((cpuv[3] >> 8) & 1);
}
@ -106,11 +106,7 @@ uint64 PPCTimer_microsecondsToTsc(uint64 us)
uint64 PPCTimer_tscToMicroseconds(uint64 us)
{
uint128_t r{};
#if BOOST_OS_WINDOWS
r.low = _umul128(us, 1000000ULL, &r.high);
#else
r.low = _umul128(us, 1000000ULL, (unsigned long long*)&r.high);
#endif
uint64 remainder;
@ -146,11 +142,7 @@ uint64 PPCTimer_getFromRDTSC()
rdtscDif = rdtscDif & ~(uint64)((sint64)rdtscDif >> 63);
uint128_t diff{};
#if BOOST_OS_WINDOWS
diff.low = _umul128(rdtscDif, Espresso::CORE_CLOCK, &diff.high);
#else
diff.low = _umul128(rdtscDif, Espresso::CORE_CLOCK, (unsigned long long*)&diff.high);
#endif
if(rdtscCurrentMeasure > _rdtscLastMeasure)
_rdtscLastMeasure = rdtscCurrentMeasure; // only travel forward in time