From 25a1a248900c0d3fc2d70f41e99c00d9c6521bfb Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Tue, 21 Dec 2021 22:04:03 +0000 Subject: [PATCH] Fallback to time(0) in mg_millis() --- mongoose.c | 4 +++- src/util.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index 0069af70..d3624554 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4475,7 +4475,7 @@ int64_t mg_millis(void) { double ticks_to_nanos = (double) timebase.numer / timebase.denom; uint64_t uptime_nanos = (uint64_t) (ticks_to_nanos * ticks); return (int64_t) (uptime_nanos / 1000000); -#else +#elif MG_ARCH == MG_ARCH_UNIX struct timespec ts; #ifdef _POSIX_MONOTONIC_CLOCK #ifdef CLOCK_MONOTONIC_RAW @@ -4487,6 +4487,8 @@ int64_t mg_millis(void) { clock_gettime(CLOCK_REALTIME, &ts); #endif return ((int64_t) ts.tv_sec * 1000 + (int64_t) ts.tv_nsec / 1000000); +#else + return time(NULL) * 1000; #endif } diff --git a/src/util.c b/src/util.c index bcc0dbf3..3caffd7b 100644 --- a/src/util.c +++ b/src/util.c @@ -317,7 +317,7 @@ int64_t mg_millis(void) { double ticks_to_nanos = (double) timebase.numer / timebase.denom; uint64_t uptime_nanos = (uint64_t) (ticks_to_nanos * ticks); return (int64_t) (uptime_nanos / 1000000); -#else +#elif MG_ARCH == MG_ARCH_UNIX struct timespec ts; #ifdef _POSIX_MONOTONIC_CLOCK #ifdef CLOCK_MONOTONIC_RAW @@ -329,5 +329,7 @@ int64_t mg_millis(void) { clock_gettime(CLOCK_REALTIME, &ts); #endif return ((int64_t) ts.tv_sec * 1000 + (int64_t) ts.tv_nsec / 1000000); +#else + return time(NULL) * 1000; #endif }