]> gitweb.factorcode.org Git - factor.git/blob - basis/random/unix/unix.factor
io.encodings.utf16: add a utf16n word for native utf16 type.
[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 hints math ;
6 IN: random.unix
7
8 TUPLE: unix-random reader ;
9
10 : <unix-random> ( path -- random )
11     binary <file-reader> unix-random boa ;
12
13 M: unix-random dispose reader>> dispose ;
14
15 M: unix-random random-bytes* ( n tuple -- byte-array )
16     reader>> stream-read ;
17
18 HINTS: M\ unix-random random-bytes* { fixnum unix-random } ;
19
20 [
21     "/dev/random" <unix-random> &dispose secure-random-generator set-global
22     "/dev/urandom" <unix-random> &dispose system-random-generator set-global
23 ] "random.unix" add-startup-hook