mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-16 10:39:49 +00:00
Fallback to time(0) in mg_millis()
This commit is contained in:
1 parent
bf7fc1d5a9
commit
25a1a24890
2 files changed
+6
-2
No files matched your search
+3
-1
@@ -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
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user