summaryrefslogtreecommitdiff
path: root/chapter25/src/main/smp/sys
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-09-28 13:30:22 -0700
committerCliff Click <cliffc@acm.org>2026-09-28 13:30:22 -0700
commit586c8f65f2d0c0e1f73aadd0aa8d850aa653bddd (patch)
tree2f539c308452ddf5fa37826da95b17ba557e8352 /chapter25/src/main/smp/sys
parent8212a66ff27e56531e0b48807088f1c544d75756 (diff)
downloadSimple-586c8f65f2d0c0e1f73aadd0aa8d850aa653bddd.tar.gz
Simple-586c8f65f2d0c0e1f73aadd0aa8d850aa653bddd.zip
Support extern C ver direct updates
FIx minor RISC encodings.
Diffstat (limited to 'chapter25/src/main/smp/sys')
-rw-r--r--chapter25/src/main/smp/sys/io.smp2
-rw-r--r--chapter25/src/main/smp/sys/libc.smp5
2 files changed, 4 insertions, 3 deletions
diff --git a/chapter25/src/main/smp/sys/io.smp b/chapter25/src/main/smp/sys/io.smp
index 33fbdb5e..d6263ffe 100644
--- a/chapter25/src/main/smp/sys/io.smp
+++ b/chapter25/src/main/smp/sys/io.smp
@@ -12,7 +12,7 @@ val read = { i32 fd ->
int len = 0;
while( true ) {
i32 rez = libc.read(fd,ptr,buf#);
- if( rez > buf# ) libc._exit(libc.errno);
+ if( rez > buf# ) libc._exit(libc.errno());
len += rez;
if( rez < buf# )
break;
diff --git a/chapter25/src/main/smp/sys/libc.smp b/chapter25/src/main/smp/sys/libc.smp
index 133b5bf7..17ee65cb 100644
--- a/chapter25/src/main/smp/sys/libc.smp
+++ b/chapter25/src/main/smp/sys/libc.smp
@@ -30,8 +30,9 @@ i32 STDERR = 2;
// status
{ i32 -> i32 } _exit = "C";
-// Error return from many native calls
-i32 errno = "C";
+// errno is not an ordinary C data symbol; read it through the native runtime.
+{ i32 } simple_errno = "C";
+val errno = { -> simple_errno(); };
// addr len prot flags fd off -> void*
{ i64 i64 i32 i32 i32 i32 -> i64 } mmap = "C";
// mmap flags