Add sanity casts for 32/64 bit correctness

This commit is contained in:
gingerBill
2021-07-12 11:03:12 +01:00
parent ff2e5c3efe
commit 76707e1d2f
10 changed files with 66 additions and 48 deletions

View File

@@ -341,7 +341,7 @@ bool sub_overflow_u64(u64 x, u64 y, u64 *result) {
}
void mul_overflow_u64(u64 x, u64 y, u64 *lo, u64 *hi) {
#if defined(GB_COMPILER_MSVC)
#if defined(GB_COMPILER_MSVC) && defined(GB_ARCH_64_BIT)
*lo = _umul128(x, y, hi);
#else
// URL(bill): https://stackoverflow.com/questions/25095741/how-can-i-multiply-64-bit-operands-and-get-128-bit-result-portably#25096197
@@ -697,9 +697,9 @@ isize next_pow2_isize(isize n) {
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
if (gb_size_of(isize) == 8) {
#if defined(GB_ARCH_64_BIT)
n |= n >> 32;
}
#endif
n++;
return n;
}