Merge branch 'master' of git://factorcode.org/git/factor
commit
a608a3c900
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2004, 2008 Slava Pestov.
|
! Copyright (C) 2004, 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: alien generic assocs kernel kernel.private math
|
USING: alien generic assocs kernel kernel.private math
|
||||||
io.nonblocking sequences strings structs sbufs threads unix
|
io.nonblocking sequences strings structs sbufs threads unix.ffi unix
|
||||||
vectors io.buffers io.backend io.encodings math.parser
|
vectors io.buffers io.backend io.encodings math.parser
|
||||||
continuations system libc qualified namespaces io.timeouts
|
continuations system libc qualified namespaces io.timeouts
|
||||||
io.encodings.utf8 accessors ;
|
io.encodings.utf8 accessors ;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
USING: alien.c-types kernel math math.bitfields namespaces
|
USING: alien.c-types kernel math math.bitfields namespaces
|
||||||
locals accessors combinators threads vectors hashtables
|
locals accessors combinators threads vectors hashtables
|
||||||
sequences assocs continuations sets
|
sequences assocs continuations sets
|
||||||
unix unix.time unix.kqueue unix.process
|
unix.ffi unix unix.time unix.kqueue unix.process
|
||||||
io.nonblocking io.unix.backend io.launcher io.unix.launcher
|
io.nonblocking io.unix.backend io.launcher io.unix.launcher
|
||||||
io.monitors ;
|
io.monitors ;
|
||||||
IN: io.unix.kqueue
|
IN: io.unix.kqueue
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespaces threads sequences byte-arrays io.nonblocking
|
||||||
io.binary io.unix.backend io.streams.duplex io.sockets.impl
|
io.binary io.unix.backend io.streams.duplex io.sockets.impl
|
||||||
io.backend io.files io.files.private io.encodings.utf8
|
io.backend io.files io.files.private io.encodings.utf8
|
||||||
math.parser continuations libc combinators system accessors
|
math.parser continuations libc combinators system accessors
|
||||||
qualified unix ;
|
qualified unix.ffi unix ;
|
||||||
|
|
||||||
EXCLUDE: io => read write close ;
|
EXCLUDE: io => read write close ;
|
||||||
EXCLUDE: io.sockets => accept ;
|
EXCLUDE: io.sockets => accept ;
|
||||||
|
|
|
@ -10,3 +10,6 @@ C-STRUCT: utimbuf
|
||||||
{ "time_t" "modtime" } ;
|
{ "time_t" "modtime" } ;
|
||||||
|
|
||||||
FUNCTION: int utime ( char* path, utimebuf* buf ) ;
|
FUNCTION: int utime ( char* path, utimebuf* buf ) ;
|
||||||
|
|
||||||
|
FUNCTION: int err_no ( ) ;
|
||||||
|
FUNCTION: char* strerror ( int errno ) ;
|
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
USING: kernel continuations sequences math accessors inference macros
|
||||||
|
fry arrays.lib unix.ffi ;
|
||||||
|
|
||||||
|
IN: unix.system-call
|
||||||
|
|
||||||
|
ERROR: unix-system-call-error word args message ;
|
||||||
|
|
||||||
|
MACRO: unix-system-call ( quot -- )
|
||||||
|
[ ] [ infer in>> ] [ first ] tri
|
||||||
|
'[
|
||||||
|
[ @ dup 0 < [ dup throw ] [ ] if ]
|
||||||
|
[ drop , narray , swap err_no strerror unix-system-call-error ]
|
||||||
|
recover
|
||||||
|
] ;
|
|
@ -2,8 +2,8 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
|
||||||
USING: alien alien.c-types alien.syntax kernel libc structs
|
USING: alien alien.c-types alien.syntax kernel libc structs
|
||||||
math namespaces system combinators vocabs.loader unix.ffi unix.types
|
math namespaces system combinators vocabs.loader qualified
|
||||||
qualified ;
|
unix.ffi unix.types unix.system-call ;
|
||||||
|
|
||||||
QUALIFIED: unix.ffi
|
QUALIFIED: unix.ffi
|
||||||
|
|
||||||
|
@ -48,7 +48,6 @@ C-STRUCT: passwd
|
||||||
|
|
||||||
! ! ! Unix functions
|
! ! ! Unix functions
|
||||||
LIBRARY: factor
|
LIBRARY: factor
|
||||||
FUNCTION: int err_no ( ) ;
|
|
||||||
FUNCTION: void clear_err_no ( ) ;
|
FUNCTION: void clear_err_no ( ) ;
|
||||||
|
|
||||||
LIBRARY: libc
|
LIBRARY: libc
|
||||||
|
@ -100,19 +99,10 @@ FUNCTION: void* mmap ( void* addr, size_t len, int prot, int flags, int fd, off_
|
||||||
FUNCTION: int munmap ( void* addr, size_t len ) ;
|
FUNCTION: int munmap ( void* addr, size_t len ) ;
|
||||||
FUNCTION: uint ntohl ( uint n ) ;
|
FUNCTION: uint ntohl ( uint n ) ;
|
||||||
FUNCTION: ushort ntohs ( ushort n ) ;
|
FUNCTION: ushort ntohs ( ushort n ) ;
|
||||||
FUNCTION: char* strerror ( int errno ) ;
|
|
||||||
|
|
||||||
ERROR: open-error path flags prot message ;
|
: open ( path flags prot -- int ) [ unix.ffi:open ] unix-system-call ;
|
||||||
|
|
||||||
: open ( path flags prot -- int )
|
: utime ( path buf -- ) [ unix.ffi:utime ] unix-system-call drop ;
|
||||||
3dup unix.ffi:open
|
|
||||||
dup 0 >= [ >r 3drop r> ] [ drop err_no strerror open-error ] if ;
|
|
||||||
|
|
||||||
ERROR: utime-error path message ;
|
|
||||||
|
|
||||||
: utime ( path buf -- )
|
|
||||||
dupd unix.ffi:utime
|
|
||||||
0 = [ drop ] [ err_no strerror utime-error ] if ;
|
|
||||||
|
|
||||||
FUNCTION: int pclose ( void* file ) ;
|
FUNCTION: int pclose ( void* file ) ;
|
||||||
FUNCTION: int pipe ( int* filedes ) ;
|
FUNCTION: int pipe ( int* filedes ) ;
|
||||||
|
|
Loading…
Reference in New Issue