summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authortrhodes <trhodes@FreeBSD.org>2003-05-01 19:09:16 +0000
committertrhodes <trhodes@FreeBSD.org>2003-05-01 19:09:16 +0000
commit66868073ad1cb9b5e5dd5f7c7b8a14627aa0a8c6 (patch)
tree6605d6d9726e7a754c4f6ac88b4bce7a43766a4a /lib/libc
parent0b64e1476ba01c6ba095af7d0623e93362281a12 (diff)
downloadFreeBSD-src-66868073ad1cb9b5e5dd5f7c7b8a14627aa0a8c6.zip
FreeBSD-src-66868073ad1cb9b5e5dd5f7c7b8a14627aa0a8c6.tar.gz
State the fact that the range is twice the traditional RAND_MAX.
Add an EXAMPLES section. PR: 48493 Submitted by: Paul Herman <pherman@frenchfries.net> (original version)
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/arc4random.317
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/libc/gen/arc4random.3 b/lib/libc/gen/arc4random.3
index dba6921..4af1472 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 ,
OpenPOWER on IntegriCloud