Skip to content

Commit 85a5f81

Browse files
authored
Fix build on 32-bit platforms (#914)
`unsigned long` is 32bit on many 32bit platforms. Use `unsigned long long` instead.
1 parent ec5fb36 commit 85a5f81

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

util/compiler.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ unsigned num_sign_bits(uint64_t n) {
4444
}
4545

4646
uint64_t add_saturate(uint64_t a, uint64_t b) {
47-
unsigned long res;
47+
unsigned long long res;
4848
static_assert(sizeof(res) == sizeof(uint64_t));
49-
return __builtin_uaddl_overflow(a, b, &res) ? UINT64_MAX : res;
49+
return __builtin_uaddll_overflow(a, b, &res) ? UINT64_MAX : res;
5050
}
5151

5252
uint64_t mul_saturate(uint64_t a, uint64_t b) {
53-
unsigned long res;
53+
unsigned long long res;
5454
static_assert(sizeof(res) == sizeof(uint64_t));
55-
return __builtin_umull_overflow(a, b, &res) ? UINT64_MAX : res;
55+
return __builtin_umulll_overflow(a, b, &res) ? UINT64_MAX : res;
5656
}
5757

5858
uint64_t divide_up(uint64_t n, uint64_t amount) {

0 commit comments

Comments
 (0)