Added _udiv128 to precompiled.h

This commit is contained in:
Tom Lally 2022-09-07 22:42:19 +01:00
parent 4eaa600b57
commit 05dd4e57e7
2 changed files with 10 additions and 11 deletions

View file

@ -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) ); }
#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)
#define UNREACHABLE __assume(false)
#elif defined(__GNUC__)