]> gitweb.factorcode.org Git - factor.git/commitdiff
unix-system-call io-error -> unix-system-call drop
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 23 Jan 2010 15:07:35 +0000 (09:07 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 23 Jan 2010 15:07:35 +0000 (09:07 -0600)
make unix.ffi, unix.ffi.linux unportable
fix spacing in io.cpp before refactoring

basis/io/backend/unix/unix.factor
basis/io/directories/unix/unix.factor
basis/io/files/info/unix/unix.factor
basis/io/files/links/unix/unix.factor
basis/io/files/unix/unix.factor
basis/io/sockets/unix/unix.factor
basis/unix/ffi/linux/tags.txt [new file with mode: 0644]
basis/unix/ffi/tags.txt [new file with mode: 0644]
basis/unix/groups/groups.factor
basis/unix/users/users.factor
vm/io.cpp

index 6412132725e9ba4947f2f43e1260dc7071082bcd..1797edccf61b8e4e9564bce0466bddb46ff382ad 100644 (file)
@@ -17,8 +17,8 @@ TUPLE: fd < disposable fd ;
 : init-fd ( fd -- fd )
     [
         |dispose
-        dup fd>> F_SETFL O_NONBLOCK [ fcntl ] unix-system-call io-error
-        dup fd>> F_SETFD FD_CLOEXEC [ fcntl ] unix-system-call io-error
+        dup fd>> F_SETFL O_NONBLOCK [ fcntl ] unix-system-call drop
+        dup fd>> F_SETFD FD_CLOEXEC [ fcntl ] unix-system-call drop
     ] with-destructors ;
 
 : <fd> ( n -- fd )
@@ -59,7 +59,7 @@ M: unix seek-handle ( n seek-type handle -- )
         { io:seek-end [ SEEK_END ] }
         [ io:bad-seek-type ]
     } case
-    [ fd>> swap ] dip [ lseek ] unix-system-call io-error ;
+    [ fd>> swap ] dip [ lseek ] unix-system-call drop ;
 
 SYMBOL: +retry+ ! just try the operation again without blocking
 SYMBOL: +input+
index a62a431de883f8ffca3fa3095ba6ef57794af9d0..77d7f2d1b27354d0be5e328c11f2c16c8c2e20a7 100644 (file)
@@ -17,29 +17,29 @@ M: unix touch-file ( path -- )
     ] if ;
 
 M: unix move-file ( from to -- )
-    [ normalize-path ] bi@ [ rename ] unix-system-call io-error ;
+    [ normalize-path ] bi@ [ rename ] unix-system-call drop ;
 
 M: unix delete-file ( path -- ) normalize-path unlink-file ;
 
 M: unix make-directory ( path -- )
-    normalize-path OCT: 777 [ mkdir ] unix-system-call io-error ;
+    normalize-path OCT: 777 [ mkdir ] unix-system-call drop ;
 
 M: unix delete-directory ( path -- )
-    normalize-path [ rmdir ] unix-system-call io-error ;
+    normalize-path [ rmdir ] unix-system-call drop ;
 
 M: unix copy-file ( from to -- )
     [ normalize-path ] bi@ call-next-method ;
 
 : with-unix-directory ( path quot -- )
-    [ [ opendir ] unix-system-call dup [ (io-error) ] unless ] dip
-    dupd curry swap '[ _ [ closedir ] unix-system-call io-error ] [ ] cleanup ; inline
+    [ opendir dup [ (io-error) ] unless ] dip
+    dupd curry swap '[ _ closedir io-error ] [ ] cleanup ; inline
 
 HOOK: find-next-file os ( DIR* -- byte-array )
 
 M: unix find-next-file ( DIR* -- byte-array )
     dirent <struct>
     f <void*>
-    [ [ readdir_r ] unix-system-call 0 = [ (io-error) ] unless ] 2keep
+    [ readdir_r 0 = [ (io-error) ] unless ] 2keep
     *void* [ drop f ] unless ;
 
 : dirent-type>file-type ( ch -- type )
index ff604759c1c324741132c9ea484465109ea0b13c..3b854679640ac7618eb2e614ce06dc0bfebde262 100644 (file)
@@ -109,7 +109,7 @@ M: unix stat>type ( stat -- type )
 
 : chmod-set-bit ( path mask ? -- )
     [ dup stat-mode ] 2dip
-    [ bitor ] [ unmask ] if [ chmod ] unix-system-call io-error ;
+    [ bitor ] [ unmask ] if [ chmod ] unix-system-call drop ;
 
 GENERIC# file-mode? 1 ( obj mask -- ? )
 
@@ -174,7 +174,7 @@ CONSTANT: ALL-EXECUTE   OCT: 0000111
 : set-other-execute ( path ? -- ) OTHER-EXECUTE swap chmod-set-bit ;
 
 : set-file-permissions ( path n -- )
-    [ normalize-path ] dip [ chmod ] unix-system-call io-error ;
+    [ normalize-path ] dip [ chmod ] unix-system-call drop ;
 
 : file-permissions ( path -- n )
     normalize-path file-info permissions>> ;
@@ -202,7 +202,7 @@ PRIVATE>
 : set-file-times ( path timestamps -- )
     #! set access, write
     [ normalize-path ] dip
-    timestamps>byte-array [ utimes ] unix-system-call io-error ;
+    timestamps>byte-array [ utimes ] unix-system-call drop ;
 
 : set-file-access-time ( path timestamp -- )
     f 2array set-file-times ;
@@ -212,7 +212,7 @@ PRIVATE>
 
 : set-file-ids ( path uid gid -- )
     [ normalize-path ] 2dip [ -1 or ] bi@
-    [ chown ] unix-system-call io-error ;
+    [ chown ] unix-system-call drop ;
 
 GENERIC: set-file-user ( path string/id -- )
 
index f97478c3321a7ba00d3c380d50b71797c7ebcb32..3f67bb453fe3299b38f60121c434fe7537f8716b 100644 (file)
@@ -5,10 +5,10 @@ sequences system unix unix.ffi ;
 IN: io.files.links.unix
 
 M: unix make-link ( path1 path2 -- )
-    normalize-path [ symlink ] unix-system-call io-error ;
+    normalize-path [ symlink ] unix-system-call drop ;
 
 M: unix make-hard-link ( path1 path2 -- )
-    normalize-path [ link ] unix-system-call io-error ;
+    normalize-path [ link ] unix-system-call drop ;
 
 M: unix read-link ( path -- path' )
     normalize-path read-symbolic-link ;
index 7293cf67fab1cff0e658886d6da87045d305d213..bf0a21f997921bd32b6256e3ea847571968b5669 100644 (file)
@@ -34,7 +34,7 @@ M: unix (file-writer) ( path -- stream )
 : open-append ( path -- fd )
     [
         append-flags file-mode open-file |dispose
-        dup 0 SEEK_END [ lseek ] unix-system-call io-error
+        dup 0 SEEK_END [ lseek ] unix-system-call drop
     ] with-destructors ;
 
 M: unix (file-appender) ( path -- stream )
index fcf84f79259c7d1a9a5b4cdb53e4694b833eb241..cc0740500a766f490a395188a9b78f2d27d78bf8 100644 (file)
@@ -77,7 +77,7 @@ M:: object establish-connection ( client-out remote -- )
 : ?bind-client ( socket -- )
     bind-local-address get [
         [ fd>> ] dip make-sockaddr/size
-        [ bind ] unix-system-call io-error
+        [ bind ] unix-system-call drop
     ] [
         drop
     ] if* ; inline
@@ -93,12 +93,12 @@ M: object ((client)) ( addrspec -- fd )
 : server-socket-fd ( addrspec type -- fd )
     [ dup protocol-family ] dip socket-fd
     [ init-server-socket ] keep
-    [ handle-fd swap make-sockaddr/size [ bind ] unix-system-call io-error ] keep ;
+    [ handle-fd swap make-sockaddr/size [ bind ] unix-system-call drop ] keep ;
 
 M: object (server) ( addrspec -- handle )
     [
         SOCK_STREAM server-socket-fd
-        dup handle-fd 128 listen io-error
+        dup handle-fd 128 [ listen ] unix-system-call drop
     ] with-destructors ;
 
 : do-accept ( server addrspec -- fd sockaddr )
diff --git a/basis/unix/ffi/linux/tags.txt b/basis/unix/ffi/linux/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/basis/unix/ffi/tags.txt b/basis/unix/ffi/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
index 7c2da50c9e143dfed3236c62462960bb71533ec0..c34affb9c33344c0dc0025faa85982498491a9ab 100644 (file)
@@ -31,12 +31,12 @@ GENERIC: group-struct ( obj -- group/f )
 
 M: integer group-struct ( id -- group/f )
     (group-struct)
-    [ [ unix.ffi:getgrgid_r ] unix-system-call io-error ] keep
+    [ [ unix.ffi:getgrgid_r ] unix-system-call drop ] keep
     check-group-struct ;
 
 M: string group-struct ( string -- group/f )
     (group-struct)
-    [ [ unix.ffi:getgrnam_r ] unix-system-call io-error ] keep
+    [ [ unix.ffi:getgrnam_r ] unix-system-call drop ] keep
     check-group-struct ;
 
 : group-struct>group ( group-struct -- group )
@@ -69,7 +69,7 @@ PRIVATE>
 : (user-groups) ( string -- seq )
     #! first group is -1337, legacy unix code
     -1337 unix.ffi:NGROUPS_MAX [ 4 * <byte-array> ] keep
-    <int> [ [ unix.ffi:getgrouplist ] unix-system-call io-error ] 2keep
+    <int> [ [ unix.ffi:getgrouplist ] unix-system-call drop ] 2keep
     [ 4 tail-slice ] [ *int 1 - ] bi* >groups ;
 
 PRIVATE>
@@ -115,10 +115,10 @@ GENERIC: set-effective-group ( obj -- )
 <PRIVATE
 
 : (set-real-group) ( id -- )
-    [ unix.ffi:setgid ] unix-system-call io-error ; inline
+    [ unix.ffi:setgid ] unix-system-call drop ; inline
 
 : (set-effective-group) ( id -- )
-    [ unix.ffi:setegid ] unix-system-call io-error ; inline
+    [ unix.ffi:setegid ] unix-system-call drop ; inline
 
 PRIVATE>
     
index b279069c59420aa53b39919b9cd8659a7aebe5f9..adf7f5ce4f320f63911dd72ca5f8d4a718ab6fb2 100644 (file)
@@ -93,10 +93,10 @@ GENERIC: set-effective-user ( string/id -- )
 <PRIVATE
 
 : (set-real-user) ( id -- )
-    [ unix.ffi:setuid ] unix-system-call io-error ; inline
+    [ unix.ffi:setuid ] unix-system-call drop ; inline
 
 : (set-effective-user) ( id -- )
-    [ unix.ffi:seteuid ] unix-system-call io-error ; inline
+    [ unix.ffi:seteuid ] unix-system-call drop ; inline
 
 PRIVATE>
 
index 9722676f315aaea85bb9e866783905c7a0a92aab..a3283b84acda4f478f6b5913778556258352ae38 100755 (executable)
--- a/vm/io.cpp
+++ b/vm/io.cpp
@@ -33,35 +33,35 @@ void factor_vm::io_error()
 
 size_t safe_fread(void *ptr, size_t size, size_t nitems, FILE *stream)
 {
-    size_t items_read = 0;
+       size_t items_read = 0;
 
-    do {
-        items_read += fread((void*)((int*)ptr+items_read*size),size,nitems-items_read,stream);
-    } while(items_read != nitems && errno == EINTR);
+       do {
+               items_read += fread((void*)((int*)ptr+items_read*size),size,nitems-items_read,stream);
+       } while(items_read != nitems && errno == EINTR);
 
-    return items_read;
+       return items_read;
 }
 
 size_t safe_fwrite(void *ptr, size_t size, size_t nitems, FILE *stream)
 {
-    size_t items_written = 0;
+       size_t items_written = 0;
 
-    do {
-        items_written += fwrite((void*)((int*)ptr+items_written*size),size,nitems-items_written,stream);
-    } while(items_written != nitems && errno == EINTR);
+       do {
+               items_written += fwrite((void*)((int*)ptr+items_written*size),size,nitems-items_written,stream);
+       } while(items_written != nitems && errno == EINTR);
 
-    return items_written;
+       return items_written;
 }
 
 int safe_fclose(FILE *stream)
 {
-    int ret = 0;
+       int ret = 0;
 
-    do {
-        ret = fclose(stream);
-    } while(ret != 0 && errno == EINTR);
+       do {
+               ret = fclose(stream);
+       } while(ret != 0 && errno == EINTR);
 
-    return ret;
+       return ret;
 }
 
 void factor_vm::primitive_fopen()