Changeset 13334
- Timestamp:
- Dec 22, 2009, 4:28:27 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/source/level-1/l1-numbers.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/level-1/l1-numbers.lisp
r13333 r13334 456 456 (%cons-mrg31k3p-state x0 x1 x2 x3 x4 x5))) 457 457 458 #+windows-target 459 (defun random-mrg31k3p-state () 460 (flet ((random-u32 () 461 (%stack-block ((buf 4)) 462 ;; BOOLEAN RtlGenRandom(PVOID buf, ULONG len) 463 (let ((r (external-call "SystemFunction036" :address buf 464 :unsigned 4 :byte))) 465 (if (plusp r) 466 (%get-unsigned-long buf) 467 (init-random-state-seeds)))))) 468 (loop repeat 6 469 for n = (random-u32) 470 ;; The first three seed elements must not be all zero, and 471 ;; likewise for the second three. Avoid the issue by 472 ;; excluding zero values. 473 collect (1+ (mod n (1- mrg31k3p-limit))) into seed 474 finally (return (apply #'%cons-mrg31k3p-state seed))))) 475 476 #-windows-target 458 477 (defun random-mrg31k3p-state () 459 478 (with-open-file (stream "/dev/urandom" :element-type '(unsigned-byte 32)
Note:
See TracChangeset
for help on using the changeset viewer.
