]> gitweb.factorcode.org Git - factor.git/commitdiff
rename err_no to errno, clear_err_no to clear-errno, move them to libc, update usages
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 7 Feb 2009 00:22:28 +0000 (18:22 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 7 Feb 2009 00:22:28 +0000 (18:22 -0600)
basis/io/backend/unix/unix.factor
basis/io/sockets/secure/unix/unix.factor
basis/io/sockets/unix/unix.factor
basis/libc/libc.factor
basis/unix/unix.factor

index 4bc8868a3c33b89672eb2149cd03ae2cd0e10a70..d86a72c6650fe2cc4ea401a4646ba57cafb9ec48 100644 (file)
@@ -84,8 +84,8 @@ M: fd refill
     fd>> over buffer>> [ buffer-end ] [ buffer-capacity ] bi read
     {
         { [ dup 0 >= ] [ swap buffer>> n>buffer f ] }
-        { [ err_no EINTR = ] [ 2drop +retry+ ] }
-        { [ err_no EAGAIN = ] [ 2drop +input+ ] }
+        { [ errno EINTR = ] [ 2drop +retry+ ] }
+        { [ errno EAGAIN = ] [ 2drop +input+ ] }
         [ (io-error) ]
     } cond ;
 
@@ -104,8 +104,8 @@ M: fd drain
             over buffer>> buffer-consume
             buffer>> buffer-empty? f +output+ ?
         ] }
-        { [ err_no EINTR = ] [ 2drop +retry+ ] }
-        { [ err_no EAGAIN = ] [ 2drop +output+ ] }
+        { [ errno EINTR = ] [ 2drop +retry+ ] }
+        { [ errno EAGAIN = ] [ 2drop +output+ ] }
         [ (io-error) ]
     } cond ;
 
@@ -143,7 +143,7 @@ M: stdin dispose*
     stdin data>> handle-fd buffer buffer-end size read
     dup 0 < [
         drop
-        err_no EINTR = [ buffer stdin size refill-stdin ] [ (io-error) ] if
+        errno EINTR = [ buffer stdin size refill-stdin ] [ (io-error) ] if
     ] [
         size = [ "Error reading stdin pipe" throw ] unless
         size buffer n>buffer
@@ -177,7 +177,7 @@ TUPLE: mx-port < port mx ;
 
 : multiplexer-error ( n -- n )
     dup 0 < [
-        err_no [ EAGAIN = ] [ EINTR = ] bi or
+        errno [ EAGAIN = ] [ EINTR = ] bi or
         [ drop 0 ] [ (io-error) ] if
     ] when ;
 
index 8419246eb626cfaedd3332331ac2a96b868b4775..f1f39a0559e93c0e0f377fa2513f35d2e2e93344 100644 (file)
@@ -15,7 +15,7 @@ M: ssl-handle handle-fd file>> handle-fd ;
     ERR_get_error dup zero? [
         drop
         {
-            { -1 [ err_no ECONNRESET = [ premature-close ] [ (io-error) ] if ] }
+            { -1 [ errno ECONNRESET = [ premature-close ] [ (io-error) ] if ] }
             { 0 [ premature-close ] }
         } case
     ] [ nip (ssl-error) ] if ;
index f209df58620654fcfb325fedaa9f8725b918e510..e701874afd951753c8959a79e63ca6887c224fb3 100644 (file)
@@ -37,8 +37,8 @@ M: object (get-remote-address) ( handle local -- sockaddr )
     dup handle>> handle-fd f 0 write
     {
         { [ 0 = ] [ drop ] }
-        { [ err_no EAGAIN = ] [ dup +output+ wait-for-port wait-to-connect ] }
-        { [ err_no EINTR = ] [ wait-to-connect ] }
+        { [ errno EAGAIN = ] [ dup +output+ wait-for-port wait-to-connect ] }
+        { [ errno EINTR = ] [ wait-to-connect ] }
         [ (io-error) ]
     } cond ;
 
@@ -46,7 +46,7 @@ M: object establish-connection ( client-out remote -- )
     [ drop ] [ [ handle>> handle-fd ] [ make-sockaddr/size ] bi* connect ] 2bi
     {
         { [ 0 = ] [ drop ] }
-        { [ err_no EINPROGRESS = ] [
+        { [ errno EINPROGRESS = ] [
             [ +output+ wait-for-port ] [ wait-to-connect ] bi
         ] }
         [ (io-error) ]
@@ -78,8 +78,8 @@ M: object (accept) ( server addrspec -- fd sockaddr )
     2dup do-accept
     {
         { [ over 0 >= ] [ [ 2nip <fd> init-fd ] dip ] }
-        { [ err_no EINTR = ] [ 2drop (accept) ] }
-        { [ err_no EAGAIN = ] [
+        { [ errno EINTR = ] [ 2drop (accept) ] }
+        { [ errno EAGAIN = ] [
             2drop
             [ drop +input+ wait-for-port ]
             [ (accept) ]
@@ -121,10 +121,10 @@ M: unix (receive) ( datagram -- packet sockaddr )
 :: do-send ( packet sockaddr len socket datagram -- )
     socket handle-fd packet dup length 0 sockaddr len sendto
     0 < [
-        err_no EINTR = [
+        errno EINTR = [
             packet sockaddr len socket datagram do-send
         ] [
-            err_no EAGAIN = [
+            errno EAGAIN = [
                 datagram +output+ wait-for-port
                 packet sockaddr len socket datagram do-send
             ] [
index 1e751833a22c759e3e3d0b9706032f260182ed3b..bcfb97750f1008e3c9eb34bc379ca3bae2bc815f 100644 (file)
@@ -2,10 +2,18 @@
 ! Copyright (C) 2007, 2008 Slava Pestov
 ! Copyright (C) 2007, 2008 Doug Coleman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien assocs continuations destructors kernel
-namespaces accessors sets summary ;
+USING: alien alien.syntax assocs continuations destructors
+kernel namespaces accessors sets summary ;
 IN: libc
 
+LIBRARY: factor
+
+: errno ( -- int )
+    "int" "factor" "err_no" { } alien-invoke ;
+
+: clear-errno ( -- )
+    "void" "factor" "clear_err_no" { } alien-invoke ;
+
 <PRIVATE
 
 : (malloc) ( size -- alien )
index 42444261e225aaa76f9e6d63a7e0090aa41df241..76613934af26a6970cbf6075e7db39819d97b1f0 100644 (file)
@@ -37,18 +37,13 @@ C-STRUCT: group
     { "int" "gr_gid" }
     { "char**" "gr_mem" } ;
 
-LIBRARY: factor
-
-FUNCTION: void clear_err_no ( ) ;
-FUNCTION: int err_no ( ) ;
-
 LIBRARY: libc
 
 FUNCTION: char* strerror ( int errno ) ;
 
 ERROR: unix-error errno message ;
 
-: (io-error) ( -- * ) err_no dup strerror unix-error ;
+: (io-error) ( -- * ) errno dup strerror unix-error ;
 
 : io-error ( n -- ) 0 < [ (io-error) ] when ;
 
@@ -61,7 +56,7 @@ MACRO:: unix-system-call ( quot -- )
             n ndup quot call dup 0 < [
                 drop
                 n narray
-                err_no dup strerror
+                errno dup strerror
                 word unix-system-call-error
             ] [
                 n nnip