mirror of
https://github.com/janet-lang/janet
synced 2025-09-01 02:18:03 +00:00
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.
This commit is contained in:
@@ -1691,7 +1691,7 @@ void janet_stream_level_triggered(JanetStream *stream) {
|
|||||||
|
|
||||||
static JanetTimestamp ts_now(void) {
|
static JanetTimestamp ts_now(void) {
|
||||||
struct timespec now;
|
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;
|
uint64_t res = 1000 * now.tv_sec;
|
||||||
res += now.tv_nsec / 1000000;
|
res += now.tv_nsec / 1000000;
|
||||||
return res;
|
return res;
|
||||||
@@ -1849,7 +1849,7 @@ JanetTimestamp to_interval(const JanetTimestamp ts) {
|
|||||||
|
|
||||||
static JanetTimestamp ts_now(void) {
|
static JanetTimestamp ts_now(void) {
|
||||||
struct timespec now;
|
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;
|
uint64_t res = 1000 * now.tv_sec;
|
||||||
res += now.tv_nsec / 1000000;
|
res += now.tv_nsec / 1000000;
|
||||||
return res;
|
return res;
|
||||||
@@ -2003,7 +2003,7 @@ void janet_ev_deinit(void) {
|
|||||||
|
|
||||||
static JanetTimestamp ts_now(void) {
|
static JanetTimestamp ts_now(void) {
|
||||||
struct timespec now;
|
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;
|
uint64_t res = 1000 * now.tv_sec;
|
||||||
res += now.tv_nsec / 1000000;
|
res += now.tv_nsec / 1000000;
|
||||||
return res;
|
return res;
|
||||||
|
Reference in New Issue
Block a user