Skip to content

Commit eabb215

Browse files
committed
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.
1 parent 697fdcf commit eabb215

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/core/ev.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ void janet_stream_level_triggered(JanetStream *stream) {
16911691

16921692
static JanetTimestamp ts_now(void) {
16931693
struct timespec now;
1694-
janet_assert(-1 != clock_gettime(CLOCK_MONOTONIC, &now), "failed to get time");
1694+
janet_assert(-1 != janet_gettime(&now, JANET_TIME_MONOTONIC), "failed to get time");
16951695
uint64_t res = 1000 * now.tv_sec;
16961696
res += now.tv_nsec / 1000000;
16971697
return res;
@@ -1849,7 +1849,7 @@ JanetTimestamp to_interval(const JanetTimestamp ts) {
18491849

18501850
static JanetTimestamp ts_now(void) {
18511851
struct timespec now;
1852-
janet_assert(-1 != clock_gettime(CLOCK_MONOTONIC, &now), "failed to get time");
1852+
janet_assert(-1 != janet_gettime(&now, JANET_TIME_MONOTONIC), "failed to get time");
18531853
uint64_t res = 1000 * now.tv_sec;
18541854
res += now.tv_nsec / 1000000;
18551855
return res;
@@ -2003,7 +2003,7 @@ void janet_ev_deinit(void) {
20032003

20042004
static JanetTimestamp ts_now(void) {
20052005
struct timespec now;
2006-
janet_assert(-1 != clock_gettime(CLOCK_REALTIME, &now), "failed to get time");
2006+
janet_assert(-1 != janet_gettime(&now, JANET_TIME_MONOTONIC), "failed to get time");
20072007
uint64_t res = 1000 * now.tv_sec;
20082008
res += now.tv_nsec / 1000000;
20092009
return res;

0 commit comments

Comments
 (0)