Skip to content

Commit

Permalink
bcachefs: fix build on 32 bit in get_random_u64_below()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kent Overstreet committed Mar 14, 2025
1 parent 90fd9ad commit 1a2b74d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/bcachefs/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1a2b74d

Please sign in to comment.