mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-28 23:49:44 +08:00
Fallback to time(0) in mg_millis()
This commit is contained in:
parent
bf7fc1d5a9
commit
25a1a24890
@ -4475,7 +4475,7 @@ int64_t mg_millis(void) {
|
|||||||
double ticks_to_nanos = (double) timebase.numer / timebase.denom;
|
double ticks_to_nanos = (double) timebase.numer / timebase.denom;
|
||||||
uint64_t uptime_nanos = (uint64_t) (ticks_to_nanos * ticks);
|
uint64_t uptime_nanos = (uint64_t) (ticks_to_nanos * ticks);
|
||||||
return (int64_t) (uptime_nanos / 1000000);
|
return (int64_t) (uptime_nanos / 1000000);
|
||||||
#else
|
#elif MG_ARCH == MG_ARCH_UNIX
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
#ifdef _POSIX_MONOTONIC_CLOCK
|
#ifdef _POSIX_MONOTONIC_CLOCK
|
||||||
#ifdef CLOCK_MONOTONIC_RAW
|
#ifdef CLOCK_MONOTONIC_RAW
|
||||||
@ -4487,6 +4487,8 @@ int64_t mg_millis(void) {
|
|||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
#endif
|
#endif
|
||||||
return ((int64_t) ts.tv_sec * 1000 + (int64_t) ts.tv_nsec / 1000000);
|
return ((int64_t) ts.tv_sec * 1000 + (int64_t) ts.tv_nsec / 1000000);
|
||||||
|
#else
|
||||||
|
return time(NULL) * 1000;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ int64_t mg_millis(void) {
|
|||||||
double ticks_to_nanos = (double) timebase.numer / timebase.denom;
|
double ticks_to_nanos = (double) timebase.numer / timebase.denom;
|
||||||
uint64_t uptime_nanos = (uint64_t) (ticks_to_nanos * ticks);
|
uint64_t uptime_nanos = (uint64_t) (ticks_to_nanos * ticks);
|
||||||
return (int64_t) (uptime_nanos / 1000000);
|
return (int64_t) (uptime_nanos / 1000000);
|
||||||
#else
|
#elif MG_ARCH == MG_ARCH_UNIX
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
#ifdef _POSIX_MONOTONIC_CLOCK
|
#ifdef _POSIX_MONOTONIC_CLOCK
|
||||||
#ifdef CLOCK_MONOTONIC_RAW
|
#ifdef CLOCK_MONOTONIC_RAW
|
||||||
@ -329,5 +329,7 @@ int64_t mg_millis(void) {
|
|||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
#endif
|
#endif
|
||||||
return ((int64_t) ts.tv_sec * 1000 + (int64_t) ts.tv_nsec / 1000000);
|
return ((int64_t) ts.tv_sec * 1000 + (int64_t) ts.tv_nsec / 1000000);
|
||||||
|
#else
|
||||||
|
return time(NULL) * 1000;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user