mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-04 05:51:19 +12:00
Added _udiv128 to precompiled.h
This commit is contained in:
parent
4eaa600b57
commit
05dd4e57e7
2 changed files with 10 additions and 11 deletions
|
@ -108,14 +108,8 @@ uint64 PPCTimer_tscToMicroseconds(uint64 us)
|
||||||
uint128_t r{};
|
uint128_t r{};
|
||||||
r.low = _umul128(us, 1000000ULL, &r.high);
|
r.low = _umul128(us, 1000000ULL, &r.high);
|
||||||
|
|
||||||
|
|
||||||
uint64 remainder;
|
uint64 remainder;
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1923 && !defined(__clang__)
|
|
||||||
const uint64 microseconds = _udiv128(r.high, r.low, _rdtscFrequency, &remainder);
|
const uint64 microseconds = _udiv128(r.high, r.low, _rdtscFrequency, &remainder);
|
||||||
#else
|
|
||||||
const uint64 microseconds = udiv128(r.low, r.high, _rdtscFrequency, &remainder);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return microseconds;
|
return microseconds;
|
||||||
}
|
}
|
||||||
|
@ -159,12 +153,7 @@ uint64 PPCTimer_getFromRDTSC()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint64 remainder;
|
uint64 remainder;
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1923 && !defined(__clang__)
|
|
||||||
uint64 elapsedTick = _udiv128(_rdtscAcc.high, _rdtscAcc.low, _rdtscFrequency, &remainder);
|
uint64 elapsedTick = _udiv128(_rdtscAcc.high, _rdtscAcc.low, _rdtscFrequency, &remainder);
|
||||||
#else
|
|
||||||
uint64 elapsedTick = udiv128(_rdtscAcc.low, _rdtscAcc.high, _rdtscFrequency, &remainder);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
_rdtscAcc.low = remainder;
|
_rdtscAcc.low = remainder;
|
||||||
_rdtscAcc.high = 0;
|
_rdtscAcc.high = 0;
|
||||||
|
|
|
@ -210,6 +210,16 @@ typedef union _LARGE_INTEGER {
|
||||||
inline T& operator^= (T& a, T b) { return reinterpret_cast<T&>( reinterpret_cast<std::underlying_type<T>::type&>(a) ^= static_cast<std::underlying_type<T>::type>(b) ); }
|
inline T& operator^= (T& a, T b) { return reinterpret_cast<T&>( reinterpret_cast<std::underlying_type<T>::type&>(a) ^= static_cast<std::underlying_type<T>::type>(b) ); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER) || defined(__clang__) // clang-cl does not support _udiv128
|
||||||
|
inline uint64 _udiv128(uint64 highDividend, uint64 lowDividend, uint64 divisor, uint64 *remainder)
|
||||||
|
{
|
||||||
|
unsigned __int128 dividend128 = (((unsigned __int128)highDividend) << 64) | ((unsigned __int128)lowDividend);
|
||||||
|
unsigned __int128 divisor128 = (unsigned __int128)divisor;
|
||||||
|
*remainder = (uint64)((dividend128 % divisor128) & 0xFFFFFFFFFFFFFFFF);
|
||||||
|
return (uint64)((dividend128 / divisor128) & 0xFFFFFFFFFFFFFFFF);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#define UNREACHABLE __assume(false)
|
#define UNREACHABLE __assume(false)
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue