Initial revision
[sbcl.git] / src / code / random.lisp
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
9
10 (in-package "SB!KERNEL")
11
12 (file-comment
13   "$Header$")
14
15 ;;; the size of the chunks returned by RANDOM-CHUNK
16 (defconstant random-chunk-length 32)
17
18 ;;; the amount that we overlap chunks by when building a large integer
19 ;;; to make up for the loss of randomness in the low bits
20 (defconstant random-integer-overlap 3)
21
22 ;;; extra bits of randomness that we generate before taking the value MOD the
23 ;;; limit, to avoid loss of randomness near the limit
24 (defconstant random-integer-extra-bits 10)
25
26 ;;; the largest fixnum we can compute from one chunk of bits
27 (defconstant random-fixnum-max
28   (1- (ash 1 (- random-chunk-length random-integer-extra-bits))))
29
30 (sb!xc:defstruct (random-state (:constructor %make-random-state))
31   (state (init-random-state) :type (simple-array (unsigned-byte 32) (627))))