libc: reduce code duplication.
parent
39093727b1
commit
7badef25ce
|
@ -97,7 +97,7 @@ M: fd refill
|
|||
errno {
|
||||
{ EINTR [ 2drop +retry+ ] }
|
||||
{ EAGAIN [ 2drop +input+ ] }
|
||||
[ throw-errno ]
|
||||
[ (throw-errno) ]
|
||||
} case
|
||||
] if ;
|
||||
|
||||
|
@ -117,7 +117,7 @@ M: fd drain
|
|||
errno {
|
||||
{ EINTR [ 2drop +retry+ ] }
|
||||
{ EAGAIN [ 2drop +output+ ] }
|
||||
[ throw-errno ]
|
||||
[ (throw-errno) ]
|
||||
} case
|
||||
] if ;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ IN: io.directories.unix.linux
|
|||
|
||||
: next-dirent ( DIR* dirent* -- dirent* ? )
|
||||
f void* <ref> [
|
||||
readdir64_r [ dup strerror libc-error ] unless-zero
|
||||
readdir64_r [ (throw-errno) ] unless-zero
|
||||
] 2keep void* deref ; inline
|
||||
|
||||
M: linux (directory-entries) ( path -- seq )
|
||||
|
|
|
@ -56,7 +56,7 @@ M: unix copy-file ( from to -- )
|
|||
|
||||
: next-dirent ( DIR* dirent* -- dirent* ? )
|
||||
f void* <ref> [
|
||||
readdir_r [ dup strerror libc-error ] unless-zero
|
||||
readdir_r [ (throw-errno) ] unless-zero
|
||||
] 2keep void* deref ; inline
|
||||
|
||||
: >directory-entry ( dirent* -- directory-entry )
|
||||
|
|
|
@ -56,7 +56,7 @@ DEFER: wait-to-connect
|
|||
errno {
|
||||
{ EAGAIN [ wait-for-output ] }
|
||||
{ EINTR [ wait-to-connect ] }
|
||||
[ throw-errno ]
|
||||
[ (throw-errno) ]
|
||||
} case
|
||||
] if ;
|
||||
|
||||
|
@ -67,7 +67,7 @@ M: object establish-connection
|
|||
errno {
|
||||
{ EINTR [ establish-connection ] }
|
||||
{ EINPROGRESS [ drop wait-for-output ] }
|
||||
[ throw-errno ]
|
||||
[ (throw-errno) ]
|
||||
} case
|
||||
] if ;
|
||||
|
||||
|
@ -114,7 +114,7 @@ M: object (accept)
|
|||
[ (accept) ]
|
||||
2bi
|
||||
] }
|
||||
[ throw-errno ]
|
||||
[ (throw-errno) ]
|
||||
} case
|
||||
] if ;
|
||||
|
||||
|
@ -157,7 +157,7 @@ M: unix (receive-unsafe)
|
|||
datagram +output+ wait-for-port
|
||||
packet sockaddr len socket datagram do-send
|
||||
] }
|
||||
[ throw-errno ]
|
||||
[ (throw-errno) ]
|
||||
} case
|
||||
] when ; inline recursive
|
||||
|
||||
|
|
|
@ -45,7 +45,9 @@ M: object strerror strerror_unsafe ;
|
|||
|
||||
ERROR: libc-error errno message ;
|
||||
|
||||
: throw-errno ( -- * ) errno dup strerror libc-error ;
|
||||
: (throw-errno) ( errno -- * ) dup strerror libc-error ;
|
||||
|
||||
: throw-errno ( -- * ) errno (throw-errno) ;
|
||||
|
||||
: io-error ( n -- ) 0 < [ throw-errno ] when ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue