1 ;;;; This software is part of the SBCL system. See the README file for
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.
10 (in-package "SB!KERNEL")
12 ;;; the size of the chunks returned by RANDOM-CHUNK
13 (def!constant random-chunk-length 32)
15 ;;; the amount that we overlap chunks by when building a large integer
16 ;;; to make up for the loss of randomness in the low bits
17 (def!constant random-integer-overlap 3)
19 ;;; extra bits of randomness that we generate before taking the value MOD the
20 ;;; limit, to avoid loss of randomness near the limit
21 (def!constant random-integer-extra-bits 10)
23 ;;; the largest fixnum we can compute from one chunk of bits
24 (def!constant random-fixnum-max
25 (1- (ash 1 (- random-chunk-length random-integer-extra-bits))))
27 (sb!xc:defstruct (random-state (:constructor %make-random-state)
28 (:copier nil)) ; since shallow copy is wrong
29 (state (init-random-state) :type (simple-array (unsigned-byte 32) (627))))