projects/linux·commit 1a2b74d0

bcachefs: fix build on 32 bit in get_random_u64_below()

1a2b74d0 · Kent Overstreet <[email protected]> · 2025-03-14 18:20:20 -04:00

bare 64 bit divides not allowed, whoops

arm-linux-gnueabi-ld: drivers/char/random.o: in function `__get_random_u64_below':
drivers/char/random.c:602:(.text+0xc70): undefined reference to `__aeabi_uldivmod'

Signed-off-by: Kent Overstreet <[email protected]>
Commit
1a2b74d0a2a46c219b25fdb0efcf9cd7f55cfe5e
Parents
90fd9ad5

Changes

1 files changed · +2 −1

FileStatusAddDelContent
fs/bcachefs/util.cmodified+2−1View file

fs/bcachefs/util.c

View file
diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c
index 8e3ab4b..da2cd11 100644
--- a/fs/bcachefs/util.c
+++ b/fs/bcachefs/util.c
@@ -663,7 +663,8 @@ u64 bch2_get_random_u64_below(u64 ceil)
u64 mult = ceil * rand;
if (unlikely(mult < ceil)) {
- u64 bound = -ceil % ceil;
+ u64 bound;
+ div64_u64_rem(-ceil, ceil, &bound);
while (unlikely(mult < bound)) {
rand = get_random_u64();
mult = ceil * rand;