]> gitweb.factorcode.org Git - factor.git/commitdiff
Allow setting errno instead of just clearing it
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 3 Feb 2010 23:20:24 +0000 (17:20 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 3 Feb 2010 23:20:24 +0000 (17:20 -0600)
basis/libc/libc.factor
vm/io.cpp
vm/io.hpp

index fe56c83516eca532fedd5cc934ea64e24238fc3d..e935d49748fd3c533479ee0e5bbeabbf5dd59d46 100644 (file)
@@ -9,8 +9,14 @@ IN: libc
 : errno ( -- int )
     int "factor" "err_no" { } alien-invoke ;
 
+: set-errno ( int -- )
+    void "factor" "set_err_no" { int } alien-invoke ;
+
 : clear-errno ( -- )
-    void "factor" "clear_err_no" { } alien-invoke ;
+    0 set-errno ;
+
+: preserve-errno ( quot -- )
+    errno [ call ] dip set-errno ; inline
 
 <PRIVATE
 
index a3283b84acda4f478f6b5913778556258352ae38..880675b212be78798a7e497f590275cd8ea37b09 100755 (executable)
--- a/vm/io.cpp
+++ b/vm/io.cpp
@@ -245,8 +245,8 @@ VM_C_API int err_no()
        return errno;
 }
 
-VM_C_API void clear_err_no()
+VM_C_API void set_err_no(int err)
 {
-       errno = 0;
+       errno = err;
 }
 }
index 41e9cec82dba096908b650a182a9b53a0def7335..c96c95863d312481045c9f1426c32a70c9c3b7b6 100755 (executable)
--- a/vm/io.hpp
+++ b/vm/io.hpp
@@ -8,6 +8,6 @@ int safe_fclose(FILE *stream);
 /* Platform specific primitives */
 
 VM_C_API int err_no();
-VM_C_API void clear_err_no();
+VM_C_API void set_err_no(int err);
 
 }