added os.exit
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sun, 12 Dec 2021 04:54:29 +0000 (22:54 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sun, 12 Dec 2021 04:54:29 +0000 (22:54 -0600)
core/os/os.onyx
core/runtime/onyx_run.onyx
modules/onyx_runtime/onyx_runtime.c

index 5aac907a6f690603b1fa402026302fbc606274ec..23c77f80cef936f4a9890654984229099057e7e9 100644 (file)
@@ -41,3 +41,6 @@ list_directory :: (path: str) -> Iterator(DirectoryEntry) {
     return .{ c, next, close };
 }
 
+exit :: (exitcode: i32) {
+    runtime.__exit(exitcode);
+}
\ No newline at end of file
index 43530fb307ee848b53e0cc967355e51be3d736c6..1b2c6d84e20132f220f9c75484f2374941f8f272 100644 (file)
@@ -14,7 +14,7 @@ __output_string :: (s: str) -> u32 {
     return wrote;
 }
 
-__exit :: (status: i32) ---
+__exit :: (status: i32) -> void #foreign "onyx_runtime" "__exit" ---
 
 __read_from_input :: (buffer: [] u8) -> i32 {
     err, read := io.stream_read(^__stdin, buffer);
index 906c4c754835852e5f74d27712d73e7fb04e3fff..1be097d656b76a332e10e7bfe6fb8808b633ce50 100644 (file)
@@ -754,6 +754,11 @@ ONYX_DEF(__process_destroy, (WASM_I64), ()) {
     return NULL;
 }
 
+ONYX_DEF(__exit, (WASM_I32), ()) {
+    exit(params->data[0].of.i32);
+    return NULL;
+}
+
 ONYX_LIBRARY {
     ONYX_FUNC(__file_open_impl)
     ONYX_FUNC(__file_close)
@@ -780,5 +785,6 @@ ONYX_LIBRARY {
     ONYX_FUNC(__process_wait)
     ONYX_FUNC(__process_destroy)
 
+    ONYX_FUNC(__exit)
     NULL
 };
\ No newline at end of file