From 7d76b7679d0b70b0e38ff08aeeeb78acde14aac3 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 25 Jan 2025 17:35:10 +0000 Subject: Use generated C headers in runtime --- runtime/src/shed/namespaces/Std/Process.c | 34 +++++++++++++++++++++++++++++++ runtime/src/shed/namespaces/Std/Process.h | 8 ++++++++ 2 files changed, 42 insertions(+) create mode 100644 runtime/src/shed/namespaces/Std/Process.c create mode 100644 runtime/src/shed/namespaces/Std/Process.h (limited to 'runtime/src/shed/namespaces/Std') 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 + +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 -- cgit v1.2.3