Page MenuHomeFreeBSD

LinuxKPI: implement get_random_u32_inclusive()
ClosedPublic

Authored by bz on May 16 2023, 9:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Aug 23, 10:07 AM
Unknown Object (File)
Mon, Aug 18, 1:28 PM
Unknown Object (File)
Jul 25 2025, 6:56 AM
Unknown Object (File)
Jul 21 2025, 9:57 PM
Unknown Object (File)
Jul 13 2025, 11:27 PM
Unknown Object (File)
Jul 8 2025, 10:19 AM
Unknown Object (File)
Jul 4 2025, 10:41 AM
Unknown Object (File)
Jun 24 2025, 2:13 AM

Details

Summary

Attempt of an implementation of get_random_u32_inclusive().
This is needed by an update for wireless drivers.

Sponsored by: The FreeBSD Foundation
MFC after: 10 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bz requested review of this revision.May 16 2023, 9:08 PM
sys/compat/linuxkpi/common/include/linux/random.h
62

low and top seem like an odd pair - I'd think low and high, bottom and top, or floor and ceil.

Change function argument names to floor/ceil as suggested by @emaste.

bz marked an inline comment as done.Jun 8 2023, 6:09 PM
hselasky added inline comments.
sys/compat/linuxkpi/common/include/linux/random.h
70

Is there a reason for the while loop? Is zero not valid for "x >> 32" ?

Maybe add:
MPASS(ceil >= floor);

Maybe add a comment showing the reference to the .PDF document explaining the formula ...

What do you think?

sys/compat/linuxkpi/common/include/linux/random.h
70

@emaste : Thanks for the link!

Address review comments.

@emaste, do you think this is okay now?

This revision was not accepted when it landed; it landed in state Needs Review.Aug 7 2023, 1:00 AM
This revision was automatically updated to reflect the committed changes.