mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-30 12:50:58 +00:00
Use uint64_t for uptime in millis, not int64_t
This commit is contained in:
1 parent
2f77855ec1
commit
a1ec179229
11 files changed
+45
-46
No files matched your search
+3
-3
@@ -80,7 +80,7 @@ int mg_check_ip_acl(struct mg_str acl, uint32_t remote_ip) {
|
||||
|
||||
#if MG_ENABLE_CUSTOM_MILLIS
|
||||
#else
|
||||
int64_t mg_millis(void) {
|
||||
uint64_t mg_millis(void) {
|
||||
#if MG_ARCH == MG_ARCH_WIN32
|
||||
return GetTickCount();
|
||||
#elif MG_ARCH == MG_ARCH_ESP32
|
||||
@@ -97,7 +97,7 @@ int64_t mg_millis(void) {
|
||||
mach_timebase_info(&timebase);
|
||||
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);
|
||||
return (uint64_t) (uptime_nanos / 1000000);
|
||||
#elif MG_ARCH == MG_ARCH_UNIX
|
||||
struct timespec ts;
|
||||
#ifdef _POSIX_MONOTONIC_CLOCK
|
||||
@@ -109,7 +109,7 @@ int64_t mg_millis(void) {
|
||||
#else
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
#endif
|
||||
return ((int64_t) ts.tv_sec * 1000 + (int64_t) ts.tv_nsec / 1000000);
|
||||
return ((uint64_t) ts.tv_sec * 1000 + (uint64_t) ts.tv_nsec / 1000000);
|
||||
#else
|
||||
return time(NULL) * 1000;
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user