From f9e872310c6e567f56b25b2ec39613a9659ed3e9 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Wed, 2 Mar 2022 13:20:04 -0600 Subject: [PATCH] added os.time --- core/os/os.onyx | 4 ++++ core/runtime/onyx_run.onyx | 2 ++ modules/onyx_runtime/onyx_runtime.c | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/core/os/os.onyx b/core/os/os.onyx index 7c5d59a8..064be058 100644 --- a/core/os/os.onyx +++ b/core/os/os.onyx @@ -48,3 +48,7 @@ exit :: (exitcode: i32) { #if #defined(runtime.__sleep) { sleep :: runtime.__sleep } + +#if #defined(runtime.__time) { + time :: runtime.__time +} diff --git a/core/runtime/onyx_run.onyx b/core/runtime/onyx_run.onyx index 6a1dcca1..c61a5ca8 100644 --- a/core/runtime/onyx_run.onyx +++ b/core/runtime/onyx_run.onyx @@ -32,6 +32,8 @@ __read_from_input :: (buffer: [] u8) -> i32 { __exit :: (status: i32) -> void --- __sleep :: (milliseconds: i32) -> void --- + + __time :: () -> u64 --- } #export "_start" () { diff --git a/modules/onyx_runtime/onyx_runtime.c b/modules/onyx_runtime/onyx_runtime.c index 231093a7..9e348dc1 100644 --- a/modules/onyx_runtime/onyx_runtime.c +++ b/modules/onyx_runtime/onyx_runtime.c @@ -787,6 +787,11 @@ ONYX_DEF(__sleep, (WASM_I32), ()) { return NULL; } +ONYX_DEF(__time, (), (WASM_I64)) { + results->data[0] = WASM_I64_VAL(bh_time_curr()); + return NULL; +} + // @@ -1044,6 +1049,7 @@ ONYX_LIBRARY { ONYX_FUNC(__exit) ONYX_FUNC(__sleep) + ONYX_FUNC(__time) ONYX_FUNC(__net_create_socket) ONYX_FUNC(__net_close_socket) -- 2.25.1