Merge branch 'master' of git://factorcode.org/git/factor

db4
Slava Pestov 2009-09-08 14:22:52 -05:00
commit a0e1af5891
4 changed files with 21 additions and 22 deletions

View File

@ -31,7 +31,7 @@ M: #branch remove-dead-code*
pad-with-bottom >>phi-in-d drop ; pad-with-bottom >>phi-in-d drop ;
: live-value-indices ( values -- indices ) : live-value-indices ( values -- indices )
[ length ] keep live-values get [ length iota ] keep live-values get
'[ _ nth _ key? ] filter ; inline '[ _ nth _ key? ] filter ; inline
: drop-indexed-values ( values indices -- node ) : drop-indexed-values ( values indices -- node )

View File

@ -5,7 +5,7 @@ io.files io.pathnames io.buffers io.ports io.timeouts
io.backend.unix io.encodings.utf8 unix.linux.inotify assocs io.backend.unix io.encodings.utf8 unix.linux.inotify assocs
namespaces make threads continuations init math math.bitwise namespaces make threads continuations init math math.bitwise
sets alien alien.strings alien.c-types vocabs.loader accessors sets alien alien.strings alien.c-types vocabs.loader accessors
system hashtables destructors unix ; system hashtables destructors unix classes.struct ;
IN: io.monitors.linux IN: io.monitors.linux
SYMBOL: watches SYMBOL: watches
@ -82,30 +82,30 @@ M: linux-monitor dispose* ( monitor -- )
] { } make prune ; ] { } make prune ;
: parse-event-name ( event -- name ) : parse-event-name ( event -- name )
dup inotify-event-len zero? dup len>> zero?
[ drop "" ] [ inotify-event-name utf8 alien>string ] if ; [ drop "" ] [ name>> utf8 alien>string ] if ;
: parse-file-notify ( buffer -- path changed ) : parse-file-notify ( buffer -- path changed )
dup inotify-event-mask ignore-flags? [ dup mask>> ignore-flags? [
drop f f drop f f
] [ ] [
[ parse-event-name ] [ inotify-event-mask parse-action ] bi [ parse-event-name ] [ mask>> parse-action ] bi
] if ; ] if ;
: events-exhausted? ( i buffer -- ? ) : events-exhausted? ( i buffer -- ? )
fill>> >= ; fill>> >= ;
: inotify-event@ ( i buffer -- alien ) : inotify-event@ ( i buffer -- inotify-event )
ptr>> <displaced-alien> ; ptr>> <displaced-alien> inotify-event memory>struct ;
: next-event ( i buffer -- i buffer ) : next-event ( i buffer -- i buffer )
2dup inotify-event@ 2dup inotify-event@
inotify-event-len "inotify-event" heap-size + len>> inotify-event heap-size +
swap [ + ] dip ; swap [ + ] dip ;
: parse-file-notifications ( i buffer -- ) : parse-file-notifications ( i buffer -- )
2dup events-exhausted? [ 2drop ] [ 2dup events-exhausted? [ 2drop ] [
2dup inotify-event@ dup inotify-event-wd wd>monitor 2dup inotify-event@ dup wd>> wd>monitor
[ parse-file-notify ] dip queue-change [ parse-file-notify ] dip queue-change
next-event parse-file-notifications next-event parse-file-notifications
] if ; ] if ;

View File

@ -1,15 +1,14 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax math math.bitwise ; USING: alien.syntax math math.bitwise classes.struct ;
IN: unix.linux.inotify IN: unix.linux.inotify
C-STRUCT: inotify-event STRUCT: inotify-event
{ "int" "wd" } ! watch descriptor { wd int }
{ "uint" "mask" } ! watch mask { mask uint }
{ "uint" "cookie" } ! cookie to synchronize two events { cookie uint }
{ "uint" "len" } ! length (including nulls) of name { len uint }
{ "char[0]" "name" } ! stub for possible name { name char[0] } ;
;
CONSTANT: IN_ACCESS HEX: 1 ! File was accessed CONSTANT: IN_ACCESS HEX: 1 ! File was accessed
CONSTANT: IN_MODIFY HEX: 2 ! File was modified CONSTANT: IN_MODIFY HEX: 2 ! File was modified
@ -28,8 +27,8 @@ CONSTANT: IN_UNMOUNT HEX: 2000 ! Backing fs was unmounted
CONSTANT: IN_Q_OVERFLOW HEX: 4000 ! Event queued overflowed CONSTANT: IN_Q_OVERFLOW HEX: 4000 ! Event queued overflowed
CONSTANT: IN_IGNORED HEX: 8000 ! File was ignored CONSTANT: IN_IGNORED HEX: 8000 ! File was ignored
: IN_CLOSE ( -- n ) IN_CLOSE_WRITE IN_CLOSE_NOWRITE bitor ; inline ! close : IN_CLOSE ( -- n ) { IN_CLOSE_WRITE IN_CLOSE_NOWRITE } flags ; foldable ! close
: IN_MOVE ( -- n ) IN_MOVED_FROM IN_MOVED_TO bitor ; inline ! moves : IN_MOVE ( -- n ) { IN_MOVED_FROM IN_MOVED_TO } flags ; foldable ! moves
CONSTANT: IN_ONLYDIR HEX: 1000000 ! only watch the path if it is a directory CONSTANT: IN_ONLYDIR HEX: 1000000 ! only watch the path if it is a directory
CONSTANT: IN_DONT_FOLLOW HEX: 2000000 ! don't follow a sym link CONSTANT: IN_DONT_FOLLOW HEX: 2000000 ! don't follow a sym link

View File

@ -99,8 +99,8 @@ M: f like drop [ f ] when-empty ; inline
INSTANCE: f immutable-sequence INSTANCE: f immutable-sequence
! Integers used to support the sequence protocol ! Integers used to support the sequence protocol
M: integer length ; inline deprecated M: integer length ; inline
M: integer nth-unsafe drop ; inline deprecated M: integer nth-unsafe drop ; inline
INSTANCE: integer immutable-sequence INSTANCE: integer immutable-sequence