Merge branch 'master' of git://factorcode.org/git/factor
commit
8e2c2e1838
|
@ -3,8 +3,8 @@
|
||||||
USING: kernel io.backend io.monitors io.monitors.private
|
USING: kernel io.backend io.monitors io.monitors.private
|
||||||
io.files io.buffers io.nonblocking io.timeouts io.unix.backend
|
io.files io.buffers io.nonblocking io.timeouts io.unix.backend
|
||||||
io.unix.select io.unix.launcher unix.linux.inotify assocs
|
io.unix.select io.unix.launcher unix.linux.inotify assocs
|
||||||
namespaces threads continuations init math
|
namespaces threads continuations init math alien.c-types alien
|
||||||
alien.c-types alien vocabs.loader ;
|
vocabs.loader accessors ;
|
||||||
IN: io.unix.linux
|
IN: io.unix.linux
|
||||||
|
|
||||||
TUPLE: linux-io ;
|
TUPLE: linux-io ;
|
||||||
|
@ -18,18 +18,16 @@ TUPLE: linux-monitor ;
|
||||||
|
|
||||||
TUPLE: inotify watches ;
|
TUPLE: inotify watches ;
|
||||||
|
|
||||||
: watches ( -- assoc ) inotify get-global inotify-watches ;
|
: watches ( -- assoc ) inotify get-global watches>> ;
|
||||||
|
|
||||||
: wd>monitor ( wd -- monitor ) watches at ;
|
: wd>monitor ( wd -- monitor ) watches at ;
|
||||||
|
|
||||||
: <inotify> ( -- port/f )
|
: <inotify> ( -- port/f )
|
||||||
H{ } clone
|
H{ } clone
|
||||||
inotify_init dup 0 < [ 2drop f ] [
|
inotify_init [ io-error ] [ inotify <buffered-port> ] bi
|
||||||
inotify <buffered-port>
|
{ set-inotify-watches set-delegate } inotify construct ;
|
||||||
{ set-inotify-watches set-delegate } inotify construct
|
|
||||||
] if ;
|
|
||||||
|
|
||||||
: inotify-fd inotify get-global port-handle ;
|
: inotify-fd inotify get-global handle>> ;
|
||||||
|
|
||||||
: (add-watch) ( path mask -- wd )
|
: (add-watch) ( path mask -- wd )
|
||||||
inotify-fd -rot inotify_add_watch dup io-error ;
|
inotify-fd -rot inotify_add_watch dup io-error ;
|
||||||
|
@ -80,10 +78,10 @@ M: linux-monitor dispose ( monitor -- )
|
||||||
parse-action swap alien>char-string ;
|
parse-action swap alien>char-string ;
|
||||||
|
|
||||||
: events-exhausted? ( i buffer -- ? )
|
: events-exhausted? ( i buffer -- ? )
|
||||||
buffer-fill >= ;
|
fill>> >= ;
|
||||||
|
|
||||||
: inotify-event@ ( i buffer -- alien )
|
: inotify-event@ ( i buffer -- alien )
|
||||||
buffer-ptr <displaced-alien> ;
|
ptr>> <displaced-alien> ;
|
||||||
|
|
||||||
: next-event ( i buffer -- i buffer )
|
: next-event ( i buffer -- i buffer )
|
||||||
2dup inotify-event@
|
2dup inotify-event@
|
||||||
|
@ -111,14 +109,17 @@ TUPLE: inotify-task ;
|
||||||
f inotify-task <input-task> ;
|
f inotify-task <input-task> ;
|
||||||
|
|
||||||
: init-inotify ( mx -- )
|
: init-inotify ( mx -- )
|
||||||
<inotify> dup inotify set-global
|
<inotify>
|
||||||
|
dup inotify set-global
|
||||||
<inotify-task> swap register-io-task ;
|
<inotify-task> swap register-io-task ;
|
||||||
|
|
||||||
M: inotify-task do-io-task ( task -- )
|
M: inotify-task do-io-task ( task -- )
|
||||||
io-task-port read-notifications f ;
|
io-task-port read-notifications f ;
|
||||||
|
|
||||||
M: linux-io init-io ( -- )
|
M: linux-io init-io ( -- )
|
||||||
<select-mx> dup mx set-global init-inotify ;
|
<select-mx>
|
||||||
|
[ mx set-global ]
|
||||||
|
[ [ init-inotify ] curry ignore-errors ] bi ;
|
||||||
|
|
||||||
T{ linux-io } set-io-backend
|
T{ linux-io } set-io-backend
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,12 @@ namespaces math math.parser openssl prettyprint sequences tools.test ;
|
||||||
]
|
]
|
||||||
[ "Hello world from the openssl binding" >md5 ] unit-test
|
[ "Hello world from the openssl binding" >md5 ] unit-test
|
||||||
|
|
||||||
[
|
! Not found on netbsd, windows -- why?
|
||||||
B{ 63 113 237 255 181 5 152 241 136 181 43 95 160 105 44 87 49
|
! [
|
||||||
82 115 0 }
|
! B{ 63 113 237 255 181 5 152 241 136 181 43 95 160 105 44 87 49
|
||||||
]
|
! 82 115 0 }
|
||||||
[ "Hello world from the openssl binding" >sha1 ] unit-test
|
! ]
|
||||||
|
! [ "Hello world from the openssl binding" >sha1 ] unit-test
|
||||||
|
|
||||||
! =========================================================
|
! =========================================================
|
||||||
! Initialize context
|
! Initialize context
|
||||||
|
|
|
@ -9,9 +9,6 @@ IN: random.mersenne-twister
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: curry2 ( w quot1 quot2 -- quot1 quot2 )
|
|
||||||
>r over r> [ curry ] 2bi@ ; inline
|
|
||||||
|
|
||||||
TUPLE: mersenne-twister seq i ;
|
TUPLE: mersenne-twister seq i ;
|
||||||
|
|
||||||
: mt-n 624 ; inline
|
: mt-n 624 ; inline
|
||||||
|
@ -27,7 +24,7 @@ TUPLE: mersenne-twister seq i ;
|
||||||
r> bitxor bitxor r> r> set-nth ; inline
|
r> bitxor bitxor r> r> set-nth ; inline
|
||||||
|
|
||||||
: calculate-y ( y1 y2 mt -- y )
|
: calculate-y ( y1 y2 mt -- y )
|
||||||
[ nth mt-hi ] [ nth mt-lo ] curry2 bi* bitor ; inline
|
tuck [ nth mt-hi ] [ nth mt-lo ] 2bi* bitor ; inline
|
||||||
|
|
||||||
: (mt-generate) ( n mt-seq -- y to from-elt )
|
: (mt-generate) ( n mt-seq -- y to from-elt )
|
||||||
[ >r dup 1+ mt-wrap r> calculate-y ]
|
[ >r dup 1+ mt-wrap r> calculate-y ]
|
||||||
|
|
Loading…
Reference in New Issue