mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
LinuxKPI: Add get_random_u32_below function
get_random_u32_below returns a random integer in the interval [0, ceil), with uniform distribution. Sponsored by: Serenity CyberSecurity, LLC Reviewed by: emaste MFC after: 1 week (cherry picked from commit 9289c1f6f1514e714b17026c50ec09282f079cba)
This commit is contained in:
parent
5496fab6a2
commit
4242e224e6
1 changed files with 6 additions and 0 deletions
|
|
@ -96,6 +96,12 @@ get_random_u64(void)
|
|||
return (val);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
get_random_u32_below(uint32_t max)
|
||||
{
|
||||
return (arc4random_uniform(max));
|
||||
}
|
||||
|
||||
static __inline uint32_t
|
||||
prandom_u32(void)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue