Merge branch 'master' into specialized-arrays
commit
1ac4b92051
|
@ -130,7 +130,7 @@ M: register modifier drop BIN: 11 ;
|
||||||
GENERIC# n, 1 ( value n -- )
|
GENERIC# n, 1 ( value n -- )
|
||||||
|
|
||||||
M: integer n, >le % ;
|
M: integer n, >le % ;
|
||||||
M: byte n, >r value>> r> n, ;
|
M: byte n, [ value>> ] dip n, ;
|
||||||
: 1, ( n -- ) 1 n, ; inline
|
: 1, ( n -- ) 1 n, ; inline
|
||||||
: 4, ( n -- ) 4 n, ; inline
|
: 4, ( n -- ) 4 n, ; inline
|
||||||
: 2, ( n -- ) 2 n, ; inline
|
: 2, ( n -- ) 2 n, ; inline
|
||||||
|
@ -209,7 +209,7 @@ M: object operand-64? drop f ;
|
||||||
: short-operand ( reg rex.w n -- )
|
: short-operand ( reg rex.w n -- )
|
||||||
#! Some instructions encode their single operand as part of
|
#! Some instructions encode their single operand as part of
|
||||||
#! the opcode.
|
#! the opcode.
|
||||||
>r dupd prefix-1 reg-code r> + , ;
|
[ dupd prefix-1 reg-code ] dip + , ;
|
||||||
|
|
||||||
: opcode, ( opcode -- ) dup array? [ % ] [ , ] if ;
|
: opcode, ( opcode -- ) dup array? [ % ] [ , ] if ;
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ M: object operand-64? drop f ;
|
||||||
: 1-operand ( op reg,rex.w,opcode -- )
|
: 1-operand ( op reg,rex.w,opcode -- )
|
||||||
#! The 'reg' is not really a register, but a value for the
|
#! The 'reg' is not really a register, but a value for the
|
||||||
#! 'reg' field of the mod-r/m byte.
|
#! 'reg' field of the mod-r/m byte.
|
||||||
first3 >r >r over r> prefix-1 r> opcode, swap addressing ;
|
first3 [ [ over ] dip prefix-1 ] dip opcode, swap addressing ;
|
||||||
|
|
||||||
: immediate-operand-size-bit ( imm dst reg,rex.w,opcode -- imm dst reg,rex.w,opcode )
|
: immediate-operand-size-bit ( imm dst reg,rex.w,opcode -- imm dst reg,rex.w,opcode )
|
||||||
pick integer? [ first3 BIN: 1 opcode-or 3array ] when ;
|
pick integer? [ first3 BIN: 1 opcode-or 3array ] when ;
|
||||||
|
@ -250,7 +250,7 @@ M: object operand-64? drop f ;
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: (2-operand) ( dst src op -- )
|
: (2-operand) ( dst src op -- )
|
||||||
>r 2dup t rex-prefix r> opcode,
|
[ 2dup t rex-prefix ] dip opcode,
|
||||||
reg-code swap addressing ;
|
reg-code swap addressing ;
|
||||||
|
|
||||||
: direction-bit ( dst src op -- dst' src' op' )
|
: direction-bit ( dst src op -- dst' src' op' )
|
||||||
|
@ -271,11 +271,11 @@ M: object operand-64? drop f ;
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: [] ( reg/displacement -- indirect )
|
: [] ( reg/displacement -- indirect )
|
||||||
dup integer? [ >r f f f r> ] [ f f f ] if <indirect> ;
|
dup integer? [ [ f f f ] dip ] [ f f f ] if <indirect> ;
|
||||||
|
|
||||||
: [+] ( reg displacement -- indirect )
|
: [+] ( reg displacement -- indirect )
|
||||||
dup integer?
|
dup integer?
|
||||||
[ dup zero? [ drop f ] when >r f f r> ]
|
[ dup zero? [ drop f ] when [ f f ] dip ]
|
||||||
[ f f ] if
|
[ f f ] if
|
||||||
<indirect> ;
|
<indirect> ;
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ USING: kernel words sequences lexer parser fry ;
|
||||||
IN: cpu.x86.assembler.syntax
|
IN: cpu.x86.assembler.syntax
|
||||||
|
|
||||||
: define-register ( name num size -- )
|
: define-register ( name num size -- )
|
||||||
>r >r "cpu.x86.assembler" create dup define-symbol r> r>
|
[ "cpu.x86.assembler" create dup define-symbol ] 2dip
|
||||||
>r dupd "register" set-word-prop r>
|
[ dupd "register" set-word-prop ] dip
|
||||||
"register-size" set-word-prop ;
|
"register-size" set-word-prop ;
|
||||||
|
|
||||||
: define-registers ( names size -- )
|
: define-registers ( names size -- )
|
||||||
|
|
|
@ -5,7 +5,7 @@ destructors ;
|
||||||
|
|
||||||
: buffer-set ( string buffer -- )
|
: buffer-set ( string buffer -- )
|
||||||
over >byte-array over ptr>> byte-array>memory
|
over >byte-array over ptr>> byte-array>memory
|
||||||
>r length r> buffer-reset ;
|
[ length ] dip buffer-reset ;
|
||||||
|
|
||||||
: string>buffer ( string -- buffer )
|
: string>buffer ( string -- buffer )
|
||||||
dup length <buffer> tuck buffer-set ;
|
dup length <buffer> tuck buffer-set ;
|
||||||
|
|
|
@ -25,7 +25,7 @@ ERROR: missing-bom ;
|
||||||
: quad-be ( stream byte -- stream char )
|
: quad-be ( stream byte -- stream char )
|
||||||
double-be over stream-read1 [
|
double-be over stream-read1 [
|
||||||
dup -2 shift BIN: 110111 number= [
|
dup -2 shift BIN: 110111 number= [
|
||||||
>r 2 shift r> BIN: 11 bitand bitor
|
[ 2 shift ] dip BIN: 11 bitand bitor
|
||||||
over stream-read1 swap append-nums HEX: 10000 +
|
over stream-read1 swap append-nums HEX: 10000 +
|
||||||
] [ 2drop dup stream-read1 drop replacement-char ] if
|
] [ 2drop dup stream-read1 drop replacement-char ] if
|
||||||
] when* ;
|
] when* ;
|
||||||
|
|
|
@ -53,7 +53,7 @@ SYMBOL: +rename-file-new+
|
||||||
SYMBOL: +rename-file+
|
SYMBOL: +rename-file+
|
||||||
|
|
||||||
: with-monitor ( path recursive? quot -- )
|
: with-monitor ( path recursive? quot -- )
|
||||||
>r <monitor> r> with-disposal ; inline
|
[ <monitor> ] dip with-disposal ; inline
|
||||||
|
|
||||||
{
|
{
|
||||||
{ [ os macosx? ] [ "io.unix.macosx.monitors" require ] }
|
{ [ os macosx? ] [ "io.unix.macosx.monitors" require ] }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
USING: accessors sequences assocs arrays continuations
|
USING: accessors sequences assocs arrays continuations
|
||||||
destructors combinators kernel threads concurrency.messaging
|
destructors combinators kernel threads concurrency.messaging
|
||||||
concurrency.mailboxes concurrency.promises io.files io.monitors
|
concurrency.mailboxes concurrency.promises io.files io.monitors
|
||||||
debugger ;
|
debugger fry ;
|
||||||
IN: io.monitors.recursive
|
IN: io.monitors.recursive
|
||||||
|
|
||||||
! Simulate recursive monitors on platforms that don't have them
|
! Simulate recursive monitors on platforms that don't have them
|
||||||
|
@ -29,10 +29,10 @@ DEFER: add-child-monitor
|
||||||
qualify-path dup link-info directory? [
|
qualify-path dup link-info directory? [
|
||||||
[ add-child-monitors ]
|
[ add-child-monitors ]
|
||||||
[
|
[
|
||||||
[
|
'[
|
||||||
[ f my-mailbox (monitor) ] keep
|
_ [ f my-mailbox (monitor) ] keep
|
||||||
monitor tget children>> set-at
|
monitor tget children>> set-at
|
||||||
] curry ignore-errors
|
] ignore-errors
|
||||||
] bi
|
] bi
|
||||||
] [ drop ] if ;
|
] [ drop ] if ;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ M: recursive-monitor dispose*
|
||||||
monitor tget children>> [ nip dispose ] assoc-each ;
|
monitor tget children>> [ nip dispose ] assoc-each ;
|
||||||
|
|
||||||
: pump-step ( msg -- )
|
: pump-step ( msg -- )
|
||||||
first3 path>> swap >r prepend-path r> monitor tget 3array
|
first3 path>> swap [ prepend-path ] dip monitor tget 3array
|
||||||
monitor tget queue>>
|
monitor tget queue>>
|
||||||
mailbox-put ;
|
mailbox-put ;
|
||||||
|
|
||||||
|
@ -71,9 +71,9 @@ M: recursive-monitor dispose*
|
||||||
|
|
||||||
: pump-loop ( -- )
|
: pump-loop ( -- )
|
||||||
receive dup synchronous? [
|
receive dup synchronous? [
|
||||||
>r stop-pump t r> reply-synchronous
|
[ stop-pump t ] dip reply-synchronous
|
||||||
] [
|
] [
|
||||||
[ [ update-hierarchy ] curry ignore-errors ] [ pump-step ] bi
|
[ '[ _ update-hierarchy ] ignore-errors ] [ pump-step ] bi
|
||||||
pump-loop
|
pump-loop
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ M: recursive-monitor dispose*
|
||||||
pump-loop ;
|
pump-loop ;
|
||||||
|
|
||||||
: start-pump-thread ( monitor -- )
|
: start-pump-thread ( monitor -- )
|
||||||
dup [ pump-thread ] curry
|
dup '[ _ pump-thread ]
|
||||||
"Recursive monitor pump" spawn
|
"Recursive monitor pump" spawn
|
||||||
>>thread drop ;
|
>>thread drop ;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ M: recursive-monitor dispose*
|
||||||
ready>> ?promise ?linked drop ;
|
ready>> ?promise ?linked drop ;
|
||||||
|
|
||||||
: <recursive-monitor> ( path mailbox -- monitor )
|
: <recursive-monitor> ( path mailbox -- monitor )
|
||||||
>r (normalize-path) r>
|
[ (normalize-path) ] dip
|
||||||
recursive-monitor new-monitor
|
recursive-monitor new-monitor
|
||||||
H{ } clone >>children
|
H{ } clone >>children
|
||||||
<promise> >>ready
|
<promise> >>ready
|
||||||
|
|
|
@ -42,7 +42,7 @@ GENERIC: make-connection ( pool -- conn )
|
||||||
[ nip call ] [ drop return-connection ] 3bi ; inline
|
[ nip call ] [ drop return-connection ] 3bi ; inline
|
||||||
|
|
||||||
: with-pooled-connection ( pool quot -- )
|
: with-pooled-connection ( pool quot -- )
|
||||||
>r [ acquire-connection ] keep r>
|
[ [ acquire-connection ] keep ] dip
|
||||||
[ (with-pooled-connection) ] [ ] [ 2drop dispose ] cleanup ; inline
|
[ (with-pooled-connection) ] [ ] [ 2drop dispose ] cleanup ; inline
|
||||||
|
|
||||||
M: return-connection dispose
|
M: return-connection dispose
|
||||||
|
|
|
@ -27,7 +27,7 @@ M: duplex-stream dispose
|
||||||
] with-destructors ;
|
] with-destructors ;
|
||||||
|
|
||||||
: <encoder-duplex> ( stream-in stream-out encoding -- duplex )
|
: <encoder-duplex> ( stream-in stream-out encoding -- duplex )
|
||||||
tuck re-encode >r re-decode r> <duplex-stream> ;
|
tuck [ re-decode ] [ re-encode ] 2bi* <duplex-stream> ;
|
||||||
|
|
||||||
: with-stream* ( stream quot -- )
|
: with-stream* ( stream quot -- )
|
||||||
[ [ in>> ] [ out>> ] bi ] dip with-streams* ; inline
|
[ [ in>> ] [ out>> ] bi ] dip with-streams* ; inline
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2008 Slava Pestov, Doug Coleman
|
! Copyright (C) 2008 Slava Pestov, Doug Coleman
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel calendar alarms io io.encodings accessors
|
USING: kernel calendar alarms io io.encodings accessors
|
||||||
namespaces ;
|
namespaces fry ;
|
||||||
IN: io.timeouts
|
IN: io.timeouts
|
||||||
|
|
||||||
GENERIC: timeout ( obj -- dt/f )
|
GENERIC: timeout ( obj -- dt/f )
|
||||||
|
@ -14,14 +14,14 @@ M: encoder set-timeout stream>> set-timeout ;
|
||||||
GENERIC: cancel-operation ( obj -- )
|
GENERIC: cancel-operation ( obj -- )
|
||||||
|
|
||||||
: queue-timeout ( obj timeout -- alarm )
|
: queue-timeout ( obj timeout -- alarm )
|
||||||
>r [ cancel-operation ] curry r> later ;
|
[ '[ _ cancel-operation ] ] dip later ;
|
||||||
|
|
||||||
: with-timeout* ( obj timeout quot -- )
|
: with-timeout* ( obj timeout quot -- )
|
||||||
3dup drop queue-timeout >r nip call r> cancel-alarm ;
|
3dup drop queue-timeout [ nip call ] dip cancel-alarm ;
|
||||||
inline
|
inline
|
||||||
|
|
||||||
: with-timeout ( obj quot -- )
|
: with-timeout ( obj quot -- )
|
||||||
over timeout [ >r dup timeout r> with-timeout* ] [ call ] if ;
|
over timeout [ [ dup timeout ] dip with-timeout* ] [ call ] if ;
|
||||||
inline
|
inline
|
||||||
|
|
||||||
: timeouts ( dt -- )
|
: timeouts ( dt -- )
|
||||||
|
|
|
@ -5,7 +5,7 @@ math io.ports sequences strings sbufs threads unix
|
||||||
vectors io.buffers io.backend io.encodings math.parser
|
vectors io.buffers io.backend io.encodings math.parser
|
||||||
continuations system libc qualified namespaces make io.timeouts
|
continuations system libc qualified namespaces make io.timeouts
|
||||||
io.encodings.utf8 destructors accessors summary combinators
|
io.encodings.utf8 destructors accessors summary combinators
|
||||||
locals unix.time ;
|
locals unix.time fry ;
|
||||||
QUALIFIED: io
|
QUALIFIED: io
|
||||||
IN: io.unix.backend
|
IN: io.unix.backend
|
||||||
|
|
||||||
|
@ -88,19 +88,16 @@ M: io-timeout summary drop "I/O operation timed out" ;
|
||||||
|
|
||||||
: wait-for-fd ( handle event -- )
|
: wait-for-fd ( handle event -- )
|
||||||
dup +retry+ eq? [ 2drop ] [
|
dup +retry+ eq? [ 2drop ] [
|
||||||
[
|
'[
|
||||||
>r
|
swap handle-fd mx get-global _ {
|
||||||
swap handle-fd
|
|
||||||
mx get-global
|
|
||||||
r> {
|
|
||||||
{ +input+ [ add-input-callback ] }
|
{ +input+ [ add-input-callback ] }
|
||||||
{ +output+ [ add-output-callback ] }
|
{ +output+ [ add-output-callback ] }
|
||||||
} case
|
} case
|
||||||
] curry "I/O" suspend nip [ io-timeout ] when
|
] "I/O" suspend nip [ io-timeout ] when
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: wait-for-port ( port event -- )
|
: wait-for-port ( port event -- )
|
||||||
[ >r handle>> r> wait-for-fd ] curry with-timeout ;
|
'[ handle>> _ wait-for-fd ] with-timeout ;
|
||||||
|
|
||||||
! Some general stuff
|
! Some general stuff
|
||||||
: file-mode OCT: 0666 ;
|
: file-mode OCT: 0666 ;
|
||||||
|
|
|
@ -36,9 +36,7 @@ TUPLE: linux-monitor < monitor wd inotify watches disposed ;
|
||||||
inotify-fd -rot inotify_add_watch dup io-error dup check-existing ;
|
inotify-fd -rot inotify_add_watch dup io-error dup check-existing ;
|
||||||
|
|
||||||
: add-watch ( path mask mailbox -- monitor )
|
: add-watch ( path mask mailbox -- monitor )
|
||||||
>r
|
[ [ (normalize-path) ] dip [ (add-watch) ] [ drop ] 2bi ] dip
|
||||||
>r (normalize-path) r>
|
|
||||||
[ (add-watch) ] [ drop ] 2bi r>
|
|
||||||
<linux-monitor> [ ] [ ] [ wd>> ] tri watches get set-at ;
|
<linux-monitor> [ ] [ ] [ wd>> ] tri watches get set-at ;
|
||||||
|
|
||||||
: check-inotify ( -- )
|
: check-inotify ( -- )
|
||||||
|
@ -103,12 +101,12 @@ M: linux-monitor dispose* ( monitor -- )
|
||||||
: 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 +
|
inotify-event-len "inotify-event" heap-size +
|
||||||
swap >r + r> ;
|
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 inotify-event-wd wd>monitor
|
||||||
>r parse-file-notify r> queue-change
|
[ parse-file-notify ] dip queue-change
|
||||||
next-event parse-file-notifications
|
next-event parse-file-notifications
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,13 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: io.backend io.monitors
|
USING: io.backend io.monitors
|
||||||
core-foundation.fsevents continuations kernel sequences
|
core-foundation.fsevents continuations kernel sequences
|
||||||
namespaces arrays system locals accessors destructors ;
|
namespaces arrays system locals accessors destructors fry ;
|
||||||
IN: io.unix.macosx.monitors
|
IN: io.unix.macosx.monitors
|
||||||
|
|
||||||
TUPLE: macosx-monitor < monitor handle ;
|
TUPLE: macosx-monitor < monitor handle ;
|
||||||
|
|
||||||
: enqueue-notifications ( triples monitor -- )
|
: enqueue-notifications ( triples monitor -- )
|
||||||
[
|
'[ first { +modify-file+ } _ queue-change ] each ;
|
||||||
>r first { +modify-file+ } r> queue-change
|
|
||||||
] curry each ;
|
|
||||||
|
|
||||||
M:: macosx (monitor) ( path recursive? mailbox -- monitor )
|
M:: macosx (monitor) ( path recursive? mailbox -- monitor )
|
||||||
[let | path [ path normalize-path ] |
|
[let | path [ path normalize-path ] |
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: alien.c-types kernel io.ports io.unix.backend
|
USING: alien.c-types kernel io.ports io.unix.backend
|
||||||
bit-arrays sequences assocs unix math namespaces
|
bit-arrays sequences assocs unix math namespaces
|
||||||
accessors math.order locals unix.time ;
|
accessors math.order locals unix.time fry ;
|
||||||
IN: io.unix.select
|
IN: io.unix.select
|
||||||
|
|
||||||
TUPLE: select-mx < mx read-fdset write-fdset ;
|
TUPLE: select-mx < mx read-fdset write-fdset ;
|
||||||
|
@ -28,7 +28,7 @@ TUPLE: select-mx < mx read-fdset write-fdset ;
|
||||||
[ check-fd ] 3curry each ; inline
|
[ check-fd ] 3curry each ; inline
|
||||||
|
|
||||||
: init-fdset ( fds fdset -- )
|
: init-fdset ( fds fdset -- )
|
||||||
[ >r t swap munge r> set-nth ] curry each ;
|
'[ t swap munge _ set-nth ] each ;
|
||||||
|
|
||||||
: read-fdset/tasks ( mx -- seq fdset )
|
: read-fdset/tasks ( mx -- seq fdset )
|
||||||
[ reads>> keys ] [ read-fdset>> ] bi ;
|
[ reads>> keys ] [ read-fdset>> ] bi ;
|
||||||
|
|
|
@ -16,18 +16,18 @@ IN: io.unix.sockets
|
||||||
0 socket dup io-error <fd> init-fd |dispose ;
|
0 socket dup io-error <fd> init-fd |dispose ;
|
||||||
|
|
||||||
: set-socket-option ( fd level opt -- )
|
: set-socket-option ( fd level opt -- )
|
||||||
>r >r handle-fd r> r> 1 <int> "int" heap-size setsockopt io-error ;
|
[ handle-fd ] 2dip 1 <int> "int" heap-size setsockopt io-error ;
|
||||||
|
|
||||||
M: unix addrinfo-error ( n -- )
|
M: unix addrinfo-error ( n -- )
|
||||||
dup zero? [ drop ] [ gai_strerror throw ] if ;
|
dup zero? [ drop ] [ gai_strerror throw ] if ;
|
||||||
|
|
||||||
! Client sockets - TCP and Unix domain
|
! Client sockets - TCP and Unix domain
|
||||||
M: object (get-local-address) ( handle remote -- sockaddr )
|
M: object (get-local-address) ( handle remote -- sockaddr )
|
||||||
>r handle-fd r> empty-sockaddr/size <int>
|
[ handle-fd ] dip empty-sockaddr/size <int>
|
||||||
[ getsockname io-error ] 2keep drop ;
|
[ getsockname io-error ] 2keep drop ;
|
||||||
|
|
||||||
M: object (get-remote-address) ( handle local -- sockaddr )
|
M: object (get-remote-address) ( handle local -- sockaddr )
|
||||||
>r handle-fd r> empty-sockaddr/size <int>
|
[ handle-fd ] dip empty-sockaddr/size <int>
|
||||||
[ getpeername io-error ] 2keep drop ;
|
[ getpeername io-error ] 2keep drop ;
|
||||||
|
|
||||||
: init-client-socket ( fd -- )
|
: init-client-socket ( fd -- )
|
||||||
|
@ -60,7 +60,7 @@ M: object ((client)) ( addrspec -- fd )
|
||||||
SOL_SOCKET SO_REUSEADDR set-socket-option ;
|
SOL_SOCKET SO_REUSEADDR set-socket-option ;
|
||||||
|
|
||||||
: server-socket-fd ( addrspec type -- fd )
|
: server-socket-fd ( addrspec type -- fd )
|
||||||
>r dup protocol-family r> socket-fd
|
[ dup protocol-family ] dip socket-fd
|
||||||
dup init-server-socket
|
dup init-server-socket
|
||||||
dup handle-fd rot make-sockaddr/size bind io-error ;
|
dup handle-fd rot make-sockaddr/size bind io-error ;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ M: object (server) ( addrspec -- handle )
|
||||||
M: object (accept) ( server addrspec -- fd sockaddr )
|
M: object (accept) ( server addrspec -- fd sockaddr )
|
||||||
2dup do-accept
|
2dup do-accept
|
||||||
{
|
{
|
||||||
{ [ over 0 >= ] [ >r 2nip <fd> init-fd r> ] }
|
{ [ over 0 >= ] [ [ 2nip <fd> init-fd ] dip ] }
|
||||||
{ [ err_no EINTR = ] [ 2drop (accept) ] }
|
{ [ err_no EINTR = ] [ 2drop (accept) ] }
|
||||||
{ [ err_no EAGAIN = ] [
|
{ [ err_no EAGAIN = ] [
|
||||||
2drop
|
2drop
|
||||||
|
|
|
@ -46,7 +46,7 @@ yield
|
||||||
|
|
||||||
"Receive 1" print
|
"Receive 1" print
|
||||||
|
|
||||||
"d" get receive >r reverse r>
|
"d" get receive [ reverse ] dip
|
||||||
|
|
||||||
"Send 1" print
|
"Send 1" print
|
||||||
dup .
|
dup .
|
||||||
|
@ -55,7 +55,7 @@ yield
|
||||||
|
|
||||||
"Receive 2" print
|
"Receive 2" print
|
||||||
|
|
||||||
"d" get receive >r " world" append r>
|
"d" get receive [ " world" append ] dip
|
||||||
|
|
||||||
"Send 1" print
|
"Send 1" print
|
||||||
dup .
|
dup .
|
||||||
|
@ -86,7 +86,7 @@ datagram-client <local> <datagram>
|
||||||
[ "olleh" t ] [
|
[ "olleh" t ] [
|
||||||
"d" get receive
|
"d" get receive
|
||||||
datagram-server <local> =
|
datagram-server <local> =
|
||||||
>r >string r>
|
[ >string ] dip
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ ] [
|
[ ] [
|
||||||
|
@ -98,7 +98,7 @@ datagram-client <local> <datagram>
|
||||||
[ "hello world" t ] [
|
[ "hello world" t ] [
|
||||||
"d" get receive
|
"d" get receive
|
||||||
datagram-server <local> =
|
datagram-server <local> =
|
||||||
>r >string r>
|
[ >string ] dip
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ ] [ "d" get dispose ] unit-test
|
[ ] [ "d" get dispose ] unit-test
|
||||||
|
|
|
@ -10,7 +10,7 @@ IN: io.windows.files
|
||||||
|
|
||||||
: open-file ( path access-mode create-mode flags -- handle )
|
: open-file ( path access-mode create-mode flags -- handle )
|
||||||
[
|
[
|
||||||
>r >r share-mode default-security-attributes r> r>
|
[ share-mode default-security-attributes ] 2dip
|
||||||
CreateFile-flags f CreateFile opened-file
|
CreateFile-flags f CreateFile opened-file
|
||||||
] with-destructors ;
|
] with-destructors ;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ IN: io.windows.files
|
||||||
GetLastError ERROR_ALREADY_EXISTS = not ;
|
GetLastError ERROR_ALREADY_EXISTS = not ;
|
||||||
|
|
||||||
: set-file-pointer ( handle length method -- )
|
: set-file-pointer ( handle length method -- )
|
||||||
>r dupd d>w/w <uint> r> SetFilePointer
|
[ dupd d>w/w <uint> ] dip SetFilePointer
|
||||||
INVALID_SET_FILE_POINTER = [
|
INVALID_SET_FILE_POINTER = [
|
||||||
CloseHandle "SetFilePointer failed" throw
|
CloseHandle "SetFilePointer failed" throw
|
||||||
] when drop ;
|
] when drop ;
|
||||||
|
@ -348,23 +348,23 @@ M: winnt file-systems ( -- array )
|
||||||
: set-file-times ( path timestamp/f timestamp/f timestamp/f -- )
|
: set-file-times ( path timestamp/f timestamp/f timestamp/f -- )
|
||||||
#! timestamp order: creation access write
|
#! timestamp order: creation access write
|
||||||
[
|
[
|
||||||
>r >r >r
|
[
|
||||||
normalize-path open-existing &dispose handle>>
|
normalize-path open-existing &dispose handle>>
|
||||||
r> r> r> (set-file-times)
|
] 3dip (set-file-times)
|
||||||
] with-destructors ;
|
] with-destructors ;
|
||||||
|
|
||||||
: set-file-create-time ( path timestamp -- )
|
: set-file-create-time ( path timestamp -- )
|
||||||
f f set-file-times ;
|
f f set-file-times ;
|
||||||
|
|
||||||
: set-file-access-time ( path timestamp -- )
|
: set-file-access-time ( path timestamp -- )
|
||||||
>r f r> f set-file-times ;
|
[ f ] dip f set-file-times ;
|
||||||
|
|
||||||
: set-file-write-time ( path timestamp -- )
|
: set-file-write-time ( path timestamp -- )
|
||||||
>r f f r> set-file-times ;
|
[ f f ] dip set-file-times ;
|
||||||
|
|
||||||
M: winnt touch-file ( path -- )
|
M: winnt touch-file ( path -- )
|
||||||
[
|
[
|
||||||
normalize-path
|
normalize-path
|
||||||
maybe-create-file >r &dispose r>
|
maybe-create-file [ &dispose ] dip
|
||||||
[ drop ] [ handle>> f now dup (set-file-times) ] if
|
[ drop ] [ handle>> f now dup (set-file-times) ] if
|
||||||
] with-destructors ;
|
] with-destructors ;
|
||||||
|
|
|
@ -18,8 +18,8 @@ C: <io-callback> io-callback
|
||||||
"OVERLAPPED" malloc-object &free ;
|
"OVERLAPPED" malloc-object &free ;
|
||||||
|
|
||||||
: make-overlapped ( port -- overlapped-ext )
|
: make-overlapped ( port -- overlapped-ext )
|
||||||
>r (make-overlapped)
|
[ (make-overlapped) ] dip
|
||||||
r> handle>> ptr>> [ over set-OVERLAPPED-offset ] when* ;
|
handle>> ptr>> [ over set-OVERLAPPED-offset ] when* ;
|
||||||
|
|
||||||
: <completion-port> ( handle existing -- handle )
|
: <completion-port> ( handle existing -- handle )
|
||||||
f 1 CreateIoCompletionPort dup win32-error=0/f ;
|
f 1 CreateIoCompletionPort dup win32-error=0/f ;
|
||||||
|
@ -64,13 +64,9 @@ M: winnt add-completion ( win32-handle -- )
|
||||||
: handle-overlapped ( us -- ? )
|
: handle-overlapped ( us -- ? )
|
||||||
wait-for-overlapped [
|
wait-for-overlapped [
|
||||||
dup [
|
dup [
|
||||||
>r drop GetLastError 1array r> resume-callback t
|
[ drop GetLastError 1array ] dip resume-callback t
|
||||||
] [
|
] [ 2drop f ] if
|
||||||
2drop f
|
] [ resume-callback t ] if ;
|
||||||
] if
|
|
||||||
] [
|
|
||||||
resume-callback t
|
|
||||||
] if ;
|
|
||||||
|
|
||||||
M: win32-handle cancel-operation
|
M: win32-handle cancel-operation
|
||||||
[ check-disposed ] [ handle>> CancelIo drop ] bi ;
|
[ check-disposed ] [ handle>> CancelIo drop ] bi ;
|
||||||
|
@ -94,7 +90,7 @@ M: winnt init-io ( -- )
|
||||||
|
|
||||||
: wait-for-file ( FileArgs n port -- n )
|
: wait-for-file ( FileArgs n port -- n )
|
||||||
swap file-error?
|
swap file-error?
|
||||||
[ 2drop 0 ] [ >r lpOverlapped>> r> twiddle-thumbs ] if ;
|
[ 2drop 0 ] [ [ lpOverlapped>> ] dip twiddle-thumbs ] if ;
|
||||||
|
|
||||||
: update-file-ptr ( n port -- )
|
: update-file-ptr ( n port -- )
|
||||||
handle>> dup ptr>> [ rot + >>ptr drop ] [ 2drop ] if* ;
|
handle>> dup ptr>> [ rot + >>ptr drop ] [ 2drop ] if* ;
|
||||||
|
|
|
@ -59,6 +59,6 @@ M: winnt FileArgs-overlapped ( port -- overlapped )
|
||||||
|
|
||||||
M: winnt open-append
|
M: winnt open-append
|
||||||
[ dup file-info size>> ] [ drop 0 ] recover
|
[ dup file-info size>> ] [ drop 0 ] recover
|
||||||
>r (open-append) r> >>ptr ;
|
[ (open-append) ] dip >>ptr ;
|
||||||
|
|
||||||
M: winnt home "USERPROFILE" os-env ;
|
M: winnt home "USERPROFILE" os-env ;
|
||||||
|
|
|
@ -52,7 +52,7 @@ IN: io.windows.nt.launcher
|
||||||
CreateFile dup invalid-handle? <win32-file> &dispose handle>> ;
|
CreateFile dup invalid-handle? <win32-file> &dispose handle>> ;
|
||||||
|
|
||||||
: redirect-append ( path access-mode create-mode -- handle )
|
: redirect-append ( path access-mode create-mode -- handle )
|
||||||
>r >r path>> r> r>
|
[ path>> ] 2dip
|
||||||
drop OPEN_ALWAYS
|
drop OPEN_ALWAYS
|
||||||
redirect-file
|
redirect-file
|
||||||
dup 0 FILE_END set-file-pointer ;
|
dup 0 FILE_END set-file-pointer ;
|
||||||
|
@ -61,7 +61,7 @@ IN: io.windows.nt.launcher
|
||||||
2drop handle>> duplicate-handle ;
|
2drop handle>> duplicate-handle ;
|
||||||
|
|
||||||
: redirect-stream ( stream access-mode create-mode -- handle )
|
: redirect-stream ( stream access-mode create-mode -- handle )
|
||||||
>r >r underlying-handle handle>> r> r> redirect-handle ;
|
[ underlying-handle handle>> ] 2dip redirect-handle ;
|
||||||
|
|
||||||
: redirect ( obj access-mode create-mode -- handle )
|
: redirect ( obj access-mode create-mode -- handle )
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,12 +20,12 @@ TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES
|
||||||
|
|
||||||
: with-process-token ( quot -- )
|
: with-process-token ( quot -- )
|
||||||
#! quot: ( token-handle -- token-handle )
|
#! quot: ( token-handle -- token-handle )
|
||||||
>r open-process-token r>
|
[ open-process-token ] dip
|
||||||
[ keep ] curry
|
[ keep ] curry
|
||||||
[ CloseHandle drop ] [ ] cleanup ; inline
|
[ CloseHandle drop ] [ ] cleanup ; inline
|
||||||
|
|
||||||
: lookup-privilege ( string -- luid )
|
: lookup-privilege ( string -- luid )
|
||||||
>r f r> "LUID" <c-object>
|
[ f ] dip "LUID" <c-object>
|
||||||
[ LookupPrivilegeValue win32-error=0/f ] keep ;
|
[ LookupPrivilegeValue win32-error=0/f ] keep ;
|
||||||
|
|
||||||
: make-token-privileges ( name ? -- obj )
|
: make-token-privileges ( name ? -- obj )
|
||||||
|
@ -39,10 +39,10 @@ TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES
|
||||||
set-LUID_AND_ATTRIBUTES-Attributes
|
set-LUID_AND_ATTRIBUTES-Attributes
|
||||||
] when
|
] when
|
||||||
|
|
||||||
>r lookup-privilege r>
|
[ lookup-privilege ] dip
|
||||||
[
|
[
|
||||||
TOKEN_PRIVILEGES-Privileges
|
TOKEN_PRIVILEGES-Privileges
|
||||||
>r 0 r> LUID_AND_ATTRIBUTES-nth
|
[ 0 ] dip LUID_AND_ATTRIBUTES-nth
|
||||||
set-LUID_AND_ATTRIBUTES-Luid
|
set-LUID_AND_ATTRIBUTES-Luid
|
||||||
] keep ;
|
] keep ;
|
||||||
|
|
||||||
|
|
|
@ -176,8 +176,8 @@ TUPLE: WSASendTo-args port
|
||||||
|
|
||||||
: make-send-buffer ( packet -- WSABUF )
|
: make-send-buffer ( packet -- WSABUF )
|
||||||
"WSABUF" malloc-object &free
|
"WSABUF" malloc-object &free
|
||||||
[ >r malloc-byte-array &free r> set-WSABUF-buf ]
|
[ [ malloc-byte-array &free ] dip set-WSABUF-buf ]
|
||||||
[ >r length r> set-WSABUF-len ]
|
[ [ length ] dip set-WSABUF-len ]
|
||||||
[ nip ]
|
[ nip ]
|
||||||
2tri ; inline
|
2tri ; inline
|
||||||
|
|
||||||
|
@ -186,8 +186,8 @@ TUPLE: WSASendTo-args port
|
||||||
swap >>port
|
swap >>port
|
||||||
dup port>> handle>> handle>> >>s
|
dup port>> handle>> handle>> >>s
|
||||||
swap make-sockaddr/size
|
swap make-sockaddr/size
|
||||||
>r malloc-byte-array &free
|
[ malloc-byte-array &free ] dip
|
||||||
r> [ >>lpTo ] [ >>iToLen ] bi*
|
[ >>lpTo ] [ >>iToLen ] bi*
|
||||||
swap make-send-buffer >>lpBuffers
|
swap make-send-buffer >>lpBuffers
|
||||||
1 >>dwBufferCount
|
1 >>dwBufferCount
|
||||||
0 >>dwFlags
|
0 >>dwFlags
|
||||||
|
|
|
@ -20,21 +20,21 @@ M: win32-socket dispose ( stream -- )
|
||||||
<win32-socket> |dispose dup add-completion ;
|
<win32-socket> |dispose dup add-completion ;
|
||||||
|
|
||||||
: open-socket ( addrspec type -- win32-socket )
|
: open-socket ( addrspec type -- win32-socket )
|
||||||
>r protocol-family r>
|
[ protocol-family ] dip
|
||||||
0 f 0 WSASocket-flags WSASocket
|
0 f 0 WSASocket-flags WSASocket
|
||||||
dup socket-error
|
dup socket-error
|
||||||
opened-socket ;
|
opened-socket ;
|
||||||
|
|
||||||
M: object (get-local-address) ( socket addrspec -- sockaddr )
|
M: object (get-local-address) ( socket addrspec -- sockaddr )
|
||||||
>r handle>> r> empty-sockaddr/size <int>
|
[ handle>> ] dip empty-sockaddr/size <int>
|
||||||
[ getsockname socket-error ] 2keep drop ;
|
[ getsockname socket-error ] 2keep drop ;
|
||||||
|
|
||||||
M: object (get-remote-address) ( socket addrspec -- sockaddr )
|
M: object (get-remote-address) ( socket addrspec -- sockaddr )
|
||||||
>r handle>> r> empty-sockaddr/size <int>
|
[ handle>> ] dip empty-sockaddr/size <int>
|
||||||
[ getpeername socket-error ] 2keep drop ;
|
[ getpeername socket-error ] 2keep drop ;
|
||||||
|
|
||||||
: bind-socket ( win32-socket sockaddr len -- )
|
: bind-socket ( win32-socket sockaddr len -- )
|
||||||
>r >r handle>> r> r> bind socket-error ;
|
[ handle>> ] 2dip bind socket-error ;
|
||||||
|
|
||||||
M: object ((client)) ( addrspec -- handle )
|
M: object ((client)) ( addrspec -- handle )
|
||||||
[ SOCK_STREAM open-socket ] keep
|
[ SOCK_STREAM open-socket ] keep
|
||||||
|
|
|
@ -8,7 +8,8 @@ splitting continuations math.bitwise system accessors ;
|
||||||
IN: io.windows
|
IN: io.windows
|
||||||
|
|
||||||
: set-inherit ( handle ? -- )
|
: set-inherit ( handle ? -- )
|
||||||
>r HANDLE_FLAG_INHERIT r> >BOOLEAN SetHandleInformation win32-error=0/f ;
|
[ HANDLE_FLAG_INHERIT ] dip
|
||||||
|
>BOOLEAN SetHandleInformation win32-error=0/f ;
|
||||||
|
|
||||||
TUPLE: win32-handle handle disposed ;
|
TUPLE: win32-handle handle disposed ;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ IN: models.range
|
||||||
|
|
||||||
TUPLE: range < compose ;
|
TUPLE: range < compose ;
|
||||||
|
|
||||||
: <range> ( value min max page -- range )
|
: <range> ( value page min max -- range )
|
||||||
4array [ <model> ] map range new-compose ;
|
4array [ <model> ] map range new-compose ;
|
||||||
|
|
||||||
: range-model ( range -- model ) dependencies>> first ;
|
: range-model ( range -- model ) dependencies>> first ;
|
||||||
|
|
|
@ -19,21 +19,15 @@ ERROR: no-vocab vocab ;
|
||||||
|
|
||||||
: root? ( string -- ? ) vocab-roots get member? ;
|
: root? ( string -- ? ) vocab-roots get member? ;
|
||||||
|
|
||||||
: length-changes? ( seq quot -- ? )
|
: contains-dot? ( string -- ? ) ".." swap subseq? ;
|
||||||
dupd call [ length ] bi@ = not ; inline
|
|
||||||
|
: contains-separator? ( string -- ? ) [ path-separator? ] contains? ;
|
||||||
|
|
||||||
: check-vocab-name ( string -- string )
|
: check-vocab-name ( string -- string )
|
||||||
dup [ [ CHAR: . = ] trim ] length-changes?
|
dup contains-dot? [ vocab-name-contains-dot ] when
|
||||||
[ vocab-name-contains-dot ] when
|
dup contains-separator? [ vocab-name-contains-separator ] when ;
|
||||||
|
|
||||||
".." over subseq? [ vocab-name-contains-dot ] when
|
|
||||||
|
|
||||||
dup [ path-separator? ] contains?
|
|
||||||
[ vocab-name-contains-separator ] when ;
|
|
||||||
|
|
||||||
: check-root ( string -- string )
|
: check-root ( string -- string )
|
||||||
check-vocab-name
|
|
||||||
dup "resource:" head? [ "resource:" prepend ] unless
|
|
||||||
dup root? [ not-a-vocab-root ] unless ;
|
dup root? [ not-a-vocab-root ] unless ;
|
||||||
|
|
||||||
: directory-exists ( path -- )
|
: directory-exists ( path -- )
|
||||||
|
|
|
@ -8,6 +8,6 @@ os {
|
||||||
{ linux [ "unix.statfs.linux" require ] }
|
{ linux [ "unix.statfs.linux" require ] }
|
||||||
{ macosx [ "unix.statfs.macosx" require ] }
|
{ macosx [ "unix.statfs.macosx" require ] }
|
||||||
{ freebsd [ "unix.statfs.freebsd" require ] }
|
{ freebsd [ "unix.statfs.freebsd" require ] }
|
||||||
! { netbsd [ "unix.statfs.netbsd" require ] }
|
{ netbsd [ ] }
|
||||||
! { openbsd [ "unix.statfs.openbsd" require ] }
|
{ openbsd [ ] }
|
||||||
} case
|
} case
|
||||||
|
|
Loading…
Reference in New Issue