]> gitweb.factorcode.org Git - factor.git/blob - basis/random/unix/unix.factor
remove BSD,solaris,etc. misc platform support code
[factor.git] / basis / random / unix / unix.factor
1 ! Copyright (C) 2008 Doug Coleman
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien.c-types io io.files kernel namespaces random
4 io.encodings.binary init accessors system destructors ;
5 IN: random.unix
6
7 TUPLE: unix-random reader ;
8
9 : <unix-random> ( path -- random )
10     binary <file-reader> unix-random boa ;
11
12 M: unix-random dispose reader>> dispose ;
13
14 M: unix-random random-bytes* ( n tuple -- byte-array )
15     reader>> stream-read ;
16
17 [
18     "/dev/random" <unix-random> &dispose secure-random-generator set-global
19     "/dev/urandom" <unix-random> &dispose system-random-generator set-global
20 ] "random.unix" add-startup-hook