Use uint64_t for uptime in millis, not int64_t

This commit is contained in:
Sergey Lyubka committed 2022-04-07 13:50:25 +01:00
1 parent 2f77855ec1
commit a1ec179229
11 files changed
+45 -46

No files matched your search

+3 -3
View File
@@ -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