summaryrefslogtreecommitdiff
path: root/sanctuary.fs
diff options
context:
space:
mode:
Diffstat (limited to 'sanctuary.fs')
-rw-r--r--sanctuary.fs12
1 files changed, 12 insertions, 0 deletions
diff --git a/sanctuary.fs b/sanctuary.fs
index 1aab4e2..e198710 100644
--- a/sanctuary.fs
+++ b/sanctuary.fs
@@ -74,6 +74,7 @@ decimal
r> dup >resolve 4 + ( u a )
postpone literal ( a ) drop ; immediate compile-only
: zstrlen dup begin dup c@ 0<> while 1+ repeat swap - ;
+\ todo s>z becomes s>z, s>z writes to pad (will then need to be moved below pno)
: s>z here -rot cmove, 0 c, ;
\ PRIVATISATION AND HIDING {{{
@@ -126,6 +127,12 @@ variable hld
: #> drop hld @ pad$ over - ;
\ }}}
+\ ERRNO {{{
+\ transform syscall result into [RESULT] IOR output,
+\ where IOR is zero on no error and negative on an error (RESULT then being 0)
+: >errno dup 0< if 0 swap else 0 then ;
+\ }}}
+
\ I/O {{{
0 constant stdin
1 constant stdout
@@ -142,6 +149,11 @@ variable hld
0 constant r/o
1 constant w/o
2 constant r/w
+
+: open-file swap >r 0 r> sys-open >errno ;
+: close-file sys-close ;
+: read-file >r swap r> sys-read >errno ;
+: write-file >r swap r> sys-write >errno ;
\ }}}
bye