From eabb215391d8ae615fbe1fbc70d00dfd07e4e7f6 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Thu, 21 Aug 2025 19:09:18 -0500 Subject: [PATCH] Use janet_gettime instead of clock_gettime in ev.c We made the wrapper, let's use it. Also switch poll implementation to a monotonic clock instead of realtime to be more inline with epoll and kqueue. --- src/core/ev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/ev.c b/src/core/ev.c index 96573d45..e63cb0ea 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -1691,7 +1691,7 @@ void janet_stream_level_triggered(JanetStream *stream) { static JanetTimestamp ts_now(void) { struct timespec now; - janet_assert(-1 != clock_gettime(CLOCK_MONOTONIC, &now), "failed to get time"); + janet_assert(-1 != janet_gettime(&now, JANET_TIME_MONOTONIC), "failed to get time"); uint64_t res = 1000 * now.tv_sec; res += now.tv_nsec / 1000000; return res; @@ -1849,7 +1849,7 @@ JanetTimestamp to_interval(const JanetTimestamp ts) { static JanetTimestamp ts_now(void) { struct timespec now; - janet_assert(-1 != clock_gettime(CLOCK_MONOTONIC, &now), "failed to get time"); + janet_assert(-1 != janet_gettime(&now, JANET_TIME_MONOTONIC), "failed to get time"); uint64_t res = 1000 * now.tv_sec; res += now.tv_nsec / 1000000; return res; @@ -2003,7 +2003,7 @@ void janet_ev_deinit(void) { static JanetTimestamp ts_now(void) { struct timespec now; - janet_assert(-1 != clock_gettime(CLOCK_REALTIME, &now), "failed to get time"); + janet_assert(-1 != janet_gettime(&now, JANET_TIME_MONOTONIC), "failed to get time"); uint64_t res = 1000 * now.tv_sec; res += now.tv_nsec / 1000000; return res;