summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/random.3
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-10-09 15:59:04 +0000
committerache <ache@FreeBSD.org>1996-10-09 15:59:04 +0000
commitc00dcd7b7aeb15d93f6f3a56b9f46d231bef265e (patch)
treed02bdd92c72dacfc58bd12cac4cdc30374fc6dea /lib/libc/stdlib/random.3
parente8d192466fe3f005269f06023c54296407ae002f (diff)
downloadFreeBSD-src-c00dcd7b7aeb15d93f6f3a56b9f46d231bef265e.zip
FreeBSD-src-c00dcd7b7aeb15d93f6f3a56b9f46d231bef265e.tar.gz
Improve seeding, the random sequence did not vary match
with the seed. Old variant will be available via libcompat soon.
Diffstat (limited to 'lib/libc/stdlib/random.3')
-rw-r--r--lib/libc/stdlib/random.329
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/libc/stdlib/random.3 b/lib/libc/stdlib/random.3
index d1b8208..dd85711 100644
--- a/lib/libc/stdlib/random.3
+++ b/lib/libc/stdlib/random.3
@@ -82,15 +82,8 @@ are usable. For example,
will produce a random binary
value.
.Pp
-Unlike
-.Xr srand ,
-.Fn srandom
-does not return the old seed; the reason for this is that the amount of
-state information used is much more than a single word. (Two other
-routines are provided to deal with restarting/changing random
-number generators). Like
+Like
.Xr rand 3 ,
-however,
.Fn random
will by default produce a sequence of numbers that can be duplicated
by calling
@@ -161,11 +154,29 @@ is called with less than 8 bytes of state information, or if
detects that the state information has been garbled, error
messages are printed on the standard error output.
.Sh SEE ALSO
-.Xr rand 3
+.Xr rand 3 ,
+.Xr srand 3
.Sh HISTORY
These
functions appeared in
.Bx 4.2 .
.Sh BUGS
+.Pp
About 2/3 the speed of
.Xr rand 3 .
+.Pp
+The historical implementation used to have a very weak seeding; the
+random sequence did not vary much with the seed. For compatibility
+reasons, this implementation has been made available until the
+next FreeBSD release
+via the
+functions
+.Fn orandom ,
+.Fn osrandom ,
+.Fn oinitstate
+and
+.Fn osetstate
+from the compatibility library,
+.Em libcompat .
+The current implementation employs a better pseudo-random number
+generator for the initial state calculation.
OpenPOWER on IntegriCloud