mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-17 10:49:47 +00:00
Use int64_t for timers and mg_millis()
This commit is contained in:
1 parent
fb0a9bc7e3
commit
ae6767b1d2
15 files changed
+123
-118
No files matched your search
+3
-4
@@ -299,7 +299,7 @@ int mg_check_ip_acl(struct mg_str acl, uint32_t remote_ip) {
|
||||
return allowed == '+';
|
||||
}
|
||||
|
||||
unsigned long mg_millis(void) {
|
||||
int64_t mg_millis(void) {
|
||||
#if MG_ARCH == MG_ARCH_WIN32
|
||||
return GetTickCount();
|
||||
#elif MG_ARCH == MG_ARCH_ESP32
|
||||
@@ -316,7 +316,7 @@ unsigned long 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 (unsigned long) (uptime_nanos / 1000000);
|
||||
return (int64_t) (uptime_nanos / 1000000);
|
||||
#else
|
||||
struct timespec ts;
|
||||
#ifdef _POSIX_MONOTONIC_CLOCK
|
||||
@@ -328,7 +328,6 @@ unsigned long mg_millis(void) {
|
||||
#else
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
#endif
|
||||
return (unsigned long) ((uint64_t) ts.tv_sec * 1000 +
|
||||
(uint64_t) ts.tv_nsec / 1000000);
|
||||
return ((int64_t) ts.tv_sec * 1000 + (int64_t) ts.tv_nsec / 1000000);
|
||||
#endif
|
||||
}
|
||||
Reference in new issue
Block a user