diff --git a/mz_os_posix.c b/mz_os_posix.c index 50b4d728..a8b4031a 100644 --- a/mz_os_posix.c +++ b/mz_os_posix.c @@ -343,8 +343,15 @@ uint64_t mz_os_ms_time(void) { ts.tv_sec = mts.tv_sec; ts.tv_nsec = mts.tv_nsec; -#else +#elif !defined(_POSIX_MONOTONIC_CLOCK) || _POSIX_MONOTONIC_CLOCK < 0 + clock_gettime(CLOCK_REALTIME, &ts); +#elif _POSIX_MONOTONIC_CLOCK > 0 clock_gettime(CLOCK_MONOTONIC, &ts); +#else + if (sysconf(_SC_MONOTONIC_CLOCK) > 0) + clock_gettime(CLOCK_MONOTONIC, &ts); + else + clock_gettime(CLOCK_REALTIME, &ts); #endif return ((uint64_t)ts.tv_sec * 1000) + ((uint64_t)ts.tv_nsec / 1000000);