aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-01-25 17:35:10 +0000
committerMichael Williamson <mike@zwobble.org>2025-01-25 17:35:10 +0000
commit7d76b7679d0b70b0e38ff08aeeeb78acde14aac3 (patch)
tree834d177f97c549e46fbea63524fa29015160ce1f /runtime
parent63c7aed6104192418ca8f44a1f8c039b5360ad99 (diff)
Use generated C headers in runtime
Diffstat (limited to 'runtime')
-rw-r--r--runtime/meson.build4
-rw-r--r--runtime/src/shed/namespaces/Shed/Builtins.c22
-rw-r--r--runtime/src/shed/namespaces/Std/Process.c34
-rw-r--r--runtime/src/shed/namespaces/Std/Process.h8
4 files changed, 45 insertions, 23 deletions
diff --git a/runtime/meson.build b/runtime/meson.build
index 3c1bb383..70bf51fd 100644
--- a/runtime/meson.build
+++ b/runtime/meson.build
@@ -21,8 +21,10 @@ static_library(
'src/shed/primitives.c',
'src/shed/strings.c',
'src/shed/namespaces/Shed/Builtins.c',
+ 'src/shed/namespaces/Std/Process.c',
gc_source,
- c_args: ['-DSHED_GC_COLLECT_INTERVAL=' + get_option('gc_collect_interval').to_string()]
+ c_args: ['-DSHED_GC_COLLECT_INTERVAL=' + get_option('gc_collect_interval').to_string()],
+ include_directories: include_directories('src')
)
if meson.get_external_property('shed_runtime_is_wasm', false)
diff --git a/runtime/src/shed/namespaces/Shed/Builtins.c b/runtime/src/shed/namespaces/Shed/Builtins.c
index 9efb4c62..12ed549d 100644
--- a/runtime/src/shed/namespaces/Shed/Builtins.c
+++ b/runtime/src/shed/namespaces/Shed/Builtins.c
@@ -24,20 +24,6 @@ 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>
@@ -54,14 +40,6 @@ 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 = {
diff --git a/runtime/src/shed/namespaces/Std/Process.c b/runtime/src/shed/namespaces/Std/Process.c
new file mode 100644
index 00000000..88fa9b6d
--- /dev/null
+++ b/runtime/src/shed/namespaces/Std/Process.c
@@ -0,0 +1,34 @@
+#include "../../std/unistd.h"
+
+#include "../../shed.h"
+#include "./Process.h"
+
+#ifdef __wasm__
+
+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__namespace__Std__Process__exit(
+ ShedClosurePointer closurePointer,
+ ShedObject exitCode
+) {
+ exit(shed__runtime__int_value(exitCode));
+ return shed_unit;
+}
+
+#endif
diff --git a/runtime/src/shed/namespaces/Std/Process.h b/runtime/src/shed/namespaces/Std/Process.h
new file mode 100644
index 00000000..23c7f5b1
--- /dev/null
+++ b/runtime/src/shed/namespaces/Std/Process.h
@@ -0,0 +1,8 @@
+#ifndef SHED_NAMESPACES__Std__Process__H
+#define SHED_NAMESPACES__Std__Process__H
+
+#include "shed/shed.h"
+
+ShedObject shed__runtime__namespace__Std__Process__exit(ShedClosurePointer closurePointer, ShedObject exitCode);
+
+#endif