1.0.35.9: Add support for non-trivial random seeds
authorNathan Froyd <froydnj@cs.rice.edu>
Thu, 11 Feb 2010 03:26:58 +0000 (03:26 +0000)
committerNathan Froyd <froydnj@cs.rice.edu>
Thu, 11 Feb 2010 03:26:58 +0000 (03:26 +0000)
commitc1a334ce597cc041447fe92f2e9adf2a5e295483
tree845d1060e43098af4a4ecabb5092a697643363a9
parentd9dc64d61bfaf26ccaad1f142ed6ecbdfb852504
1.0.35.9: Add support for non-trivial random seeds

SBCL is using the popular MT19937 PRNG algorithm, but up until now,
was only seeding the initial random state with a 32-bit seed, and
choosing a seed subject to a lot of collisions (a second-precise timer)
when called with (MAKE-RANDOM-STATE T).

This patch adds and documents an SBCL extension to MAKE-RANDOM-STATE
that supports initializing a random-state based on an arbitrary UNSIGNED-BYTE
or a (SIMPLE-ARRAY (UNSIGNED-BYTE 8)). Also supported (but documented as
not officially so) is a (SIMPLE-ARRAY (UNSIGNED-BYTE 32)). Last but not least,
(MAKE-RANDOM-STATE T) will try to initialize the random state by reading
256 bits from /dev/urandom, which should eliminate the collision problem and
make SBCL's PRNG suitable for more applications than before.

Finally, we use in our random-state initialization routines the very same
algorithms that the author of MT19937 recommends in the latest version
of his C source, and we have tested the output to be identical (see
November 2009 discussion in the sbcl-devel mailing-list).
NEWS
src/code/target-random.lisp
src/compiler/fndb.lisp
version.lisp-expr