Commit 77d9f278 authored by Peter Billam's avatar Peter Billam

fudge urandom if /dev/urandom is not present

parent cf86db69
......@@ -64,10 +64,18 @@ gauss_rand pop % initialise, and discard the resulting zero
/urandom { % random integer between 0 and 2^31 - 1
5 dict begin
/rf (/dev/urandom) (r) file def
rf read pop 256 mul rf read pop add 256 mul rf read pop add
rf read pop 128 mul rf read pop add % remains on stack
rf closefile
/fn (/dev/urandom) def
fn status {
[ /created /referenced /bytes /pages ] { exch def } forall
/rf fn (r) file def
rf read pop
256 mul rf read pop add
256 mul rf read pop add
128 mul rf read pop add % remains on stack
rf closefile
} {
usertime realtime add % sad kludge
} ifelse
} def
/randomget { % usage: [ an array ] randomget
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment