aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/shed/namespaces
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-01-17 23:32:18 +0000
committerMichael Williamson <mike@zwobble.org>2025-01-17 23:32:18 +0000
commit436f43fa2667c77ef8a7d05bb5b8001c17c7822b (patch)
tree364fece3c5f4833713b1fd7d6e9f1a99dc8dd0a0 /runtime/src/shed/namespaces
parent7c5489a16401738969f87bd1a5d89d0e1e736f99 (diff)
Add support for native functions
Diffstat (limited to 'runtime/src/shed/namespaces')
-rw-r--r--runtime/src/shed/namespaces/Shed/Builtins.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/runtime/src/shed/namespaces/Shed/Builtins.c b/runtime/src/shed/namespaces/Shed/Builtins.c
index 142a1317..9efb4c62 100644
--- a/runtime/src/shed/namespaces/Shed/Builtins.c
+++ b/runtime/src/shed/namespaces/Shed/Builtins.c
@@ -24,8 +24,24 @@ ShedObject shed__runtime__print(ShedClosurePointer closurePointer, ShedString va
return shed_unit;
}
+void wasi_proc_exit(uint32_t exitcode)
+ __attribute__((
+ __import_module__("wasi_snapshot_preview1"),
+ __import_name__("proc_exit"),
+ ));
+
+ShedObject shed__runtime__namespace__Std__Process__exit(
+ ShedClosurePointer closurePointer,
+ ShedObject exitCode
+) {
+ wasi_proc_exit(shed__runtime__int_value(exitCode));
+ return shed_unit;
+}
+
#else
+#include <stdlib.h>
+
ShedObject shed__runtime__print(ShedClosurePointer closurePointer, ShedString value) {
size_t total_bytes_written = 0;
while (total_bytes_written < value->length) {
@@ -38,6 +54,14 @@ ShedObject shed__runtime__print(ShedClosurePointer closurePointer, ShedString va
return shed_unit;
}
+ShedObject shed__runtime__namespace__Std__Process__exit(
+ ShedClosurePointer closurePointer,
+ ShedObject exitCode
+) {
+ exit(shed__runtime__int_value(exitCode));
+ return shed_unit;
+}
+
#endif
ShedClosureStruct shed__runtime__print_closure = {