diff options
Diffstat (limited to 'lib/libc/gen/arc4random.3')
| -rw-r--r-- | lib/libc/gen/arc4random.3 | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/libc/gen/arc4random.3 b/lib/libc/gen/arc4random.3 index dba6921f39fb..4af1472fdd3d 100644 --- a/lib/libc/gen/arc4random.3 +++ b/lib/libc/gen/arc4random.3 @@ -57,7 +57,13 @@ The S-Boxes can be in about .if t 2\u\s71700\s10\d .if n (2**1700) -states. +states. The +.Fn arc4random +function returns pseudo-random numbers in the range of 0 to +.if t 2\u\s731\s10\d\(mi1, +.if n (2**31)\(mi1, +and therefore has twice the range of +.Dv RAND_MAX . .Pp The .Fn arc4random_stir @@ -73,6 +79,15 @@ before using since .Fn arc4random automatically initializes itself. +.Sh EXAMPLES +The following produces a drop-in replacement for the traditional +.Fn rand +and +.Fn random +functions using +.Fn arc4random : +.Pp +.Dv #define Fn foo4random ( Fn arc4random Ft % ((unsigned)RAND_MAX + 1)) .Sh SEE ALSO .Xr rand 3 , .Xr random 3 , |
