Skip to content

Commit 1a2b74d

Browse files
author
Kent Overstreet
committed
bcachefs: fix build on 32 bit in get_random_u64_below()
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 <kent.overstreet@linux.dev>
1 parent 90fd9ad commit 1a2b74d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/bcachefs/util.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,8 @@ u64 bch2_get_random_u64_below(u64 ceil)
663663
u64 mult = ceil * rand;
664664

665665
if (unlikely(mult < ceil)) {
666-
u64 bound = -ceil % ceil;
666+
u64 bound;
667+
div64_u64_rem(-ceil, ceil, &bound);
667668
while (unlikely(mult < bound)) {
668669
rand = get_random_u64();
669670
mult = ceil * rand;

0 commit comments

Comments
 (0)