diff --git a/extra/io/unix/mmap/mmap.factor b/extra/io/unix/mmap/mmap.factor index 71c55f2303..f042366b13 100755 --- a/extra/io/unix/mmap/mmap.factor +++ b/extra/io/unix/mmap/mmap.factor @@ -10,12 +10,12 @@ IN: io.unix.mmap >r f -roll r> open-r/w [ 0 mmap ] keep over MAP_FAILED = [ close (io-error) ] when ; -M: unix-io ( path length -- obj ) +M: unix ( path length -- obj ) swap >r dup PROT_READ PROT_WRITE bitor MAP_FILE MAP_SHARED bitor r> mmap-open f mapped-file construct-boa ; -M: unix-io close-mapped-file ( mmap -- ) +M: unix close-mapped-file ( mmap -- ) [ mapped-file-address ] keep [ mapped-file-length munmap ] keep mapped-file-handle close diff --git a/extra/io/unix/sockets/sockets.factor b/extra/io/unix/sockets/sockets.factor index 69ce6a3069..477757e0ed 100755 --- a/extra/io/unix/sockets/sockets.factor +++ b/extra/io/unix/sockets/sockets.factor @@ -7,7 +7,7 @@ USING: alien alien.c-types generic io kernel math namespaces io.nonblocking parser threads unix sequences byte-arrays io.sockets io.binary io.unix.backend io.streams.duplex io.sockets.impl math.parser continuations libc -combinators io.backend io.files ; +combinators io.backend io.files system ; IN: io.unix.sockets : pending-init-error ( port -- ) @@ -23,7 +23,7 @@ IN: io.unix.sockets : sockopt ( fd level opt -- ) 1 "int" heap-size setsockopt io-error ; -M: unix-io addrinfo-error ( n -- ) +M: unix addrinfo-error ( n -- ) dup zero? [ drop ] [ gai_strerror throw ] if ; ! Client sockets - TCP and Unix domain @@ -42,7 +42,7 @@ M: connect-task do-io-task : wait-to-connect ( port -- ) [ add-io-task ] with-port-continuation drop ; -M: unix-io (client) ( addrspec -- client-in client-out ) +M: unix (client) ( addrspec -- client-in client-out ) dup make-sockaddr/size >r >r protocol-family SOCK_STREAM socket-fd dup r> r> connect @@ -91,11 +91,11 @@ USE: io.sockets dup rot make-sockaddr/size bind zero? [ dup close (io-error) ] unless ; -M: unix-io (server) ( addrspec -- handle ) +M: unix (server) ( addrspec -- handle ) SOCK_STREAM server-fd dup 10 listen zero? [ dup close (io-error) ] unless ; -M: unix-io (accept) ( server -- addrspec handle ) +M: unix (accept) ( server -- addrspec handle ) #! Wait for a client connection. dup check-server-port dup wait-to-accept @@ -104,7 +104,7 @@ M: unix-io (accept) ( server -- addrspec handle ) swap server-port-client ; ! Datagram sockets - UDP and Unix domain -M: unix-io +M: unix [ SOCK_DGRAM server-fd ] keep ; SYMBOL: receive-buffer @@ -147,7 +147,7 @@ M: receive-task do-io-task : wait-receive ( stream -- ) [ add-io-task ] with-port-continuation drop ; -M: unix-io receive ( datagram -- packet addrspec ) +M: unix receive ( datagram -- packet addrspec ) dup check-datagram-port dup wait-receive dup pending-error @@ -179,7 +179,7 @@ M: send-task do-io-task [ add-io-task ] with-port-continuation 2drop 2drop ; -M: unix-io send ( packet addrspec datagram -- ) +M: unix send ( packet addrspec datagram -- ) 3dup check-datagram-send [ >r make-sockaddr/size r> wait-send ] keep pending-error ; diff --git a/extra/io/unix/unix.factor b/extra/io/unix/unix.factor index f6607d98f9..b4328f31b3 100755 --- a/extra/io/unix/unix.factor +++ b/extra/io/unix/unix.factor @@ -1,5 +1,5 @@ USING: io.unix.backend io.unix.files io.unix.sockets io.timeouts io.unix.launcher io.unix.mmap io.backend combinators namespaces -system vocabs.loader sequences ; +system vocabs.loader sequences words ; "io.unix." os word-name append require diff --git a/extra/unix/bsd/bsd.factor b/extra/unix/bsd/bsd.factor index 6cb5d6385b..d80db44348 100755 --- a/extra/unix/bsd/bsd.factor +++ b/extra/unix/bsd/bsd.factor @@ -73,8 +73,8 @@ C-STRUCT: sockaddr-un : SEEK_END 2 ; inline os { - { "macosx" [ "unix.bsd.macosx" require ] } - { "freebsd" [ "unix.bsd.freebsd" require ] } - { "openbsd" [ "unix.bsd.openbsd" require ] } - { "netbsd" [ "unix.bsd.netbsd" require ] } + { macosx [ "unix.bsd.macosx" require ] } + { freebsd [ "unix.bsd.freebsd" require ] } + { openbsd [ "unix.bsd.openbsd" require ] } + { netbsd [ "unix.bsd.netbsd" require ] } } case diff --git a/extra/unix/kqueue/kqueue.factor b/extra/unix/kqueue/kqueue.factor index 50020072c5..080820ebd0 100644 --- a/extra/unix/kqueue/kqueue.factor +++ b/extra/unix/kqueue/kqueue.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax system sequences vocabs.loader ; +USING: alien.syntax system sequences vocabs.loader words ; IN: unix.kqueue << "unix.kqueue." os word-name append require >> diff --git a/extra/unix/types/types.factor b/extra/unix/types/types.factor index 983d5d677d..0ac2fa608e 100644 --- a/extra/unix/types/types.factor +++ b/extra/unix/types/types.factor @@ -1,17 +1,14 @@ - -USING: kernel system alien.syntax combinators vocabs.loader ; - +USING: kernel system alien.syntax combinators vocabs.loader +system ; IN: unix.types TYPEDEF: void* caddr_t -os - { - { "linux" [ "unix.types.linux" require ] } - { "macosx" [ "unix.types.macosx" require ] } - { "freebsd" [ "unix.types.freebsd" require ] } - { "openbsd" [ "unix.types.openbsd" require ] } - { "netbsd" [ "unix.types.netbsd" require ] } - { "winnt" [ ] } - } -case +os { + { linux [ "unix.types.linux" require ] } + { macosx [ "unix.types.macosx" require ] } + { freebsd [ "unix.types.freebsd" require ] } + { openbsd [ "unix.types.openbsd" require ] } + { netbsd [ "unix.types.netbsd" require ] } + { winnt [ ] } +} case diff --git a/extra/unix/unix.factor b/extra/unix/unix.factor index ffd102901c..e911a5c039 100755 --- a/extra/unix/unix.factor +++ b/extra/unix/unix.factor @@ -161,8 +161,8 @@ FUNCTION: pid_t waitpid ( pid_t wpid, int* status, int options ) ; FUNCTION: ssize_t write ( int fd, void* buf, size_t nbytes ) ; { - { [ linux? ] [ "unix.linux" require ] } - { [ bsd? ] [ "unix.bsd" require ] } - { [ solaris? ] [ "unix.solaris" require ] } + { [ os linux? ] [ "unix.linux" require ] } + { [ os bsd? ] [ "unix.bsd" require ] } + { [ os solaris? ] [ "unix.solaris" require ] } } cond