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

+4 -4
View File
@@ -6,7 +6,7 @@
struct mg_timer *g_timers;
void mg_timer_init(struct mg_timer *t, int64_t ms, unsigned flags,
void mg_timer_init(struct mg_timer *t, uint64_t ms, unsigned flags,
void (*fn)(void *), void *arg) {
struct mg_timer tmp = {ms, 0UL, flags, fn, arg, g_timers};
*t = tmp;
@@ -20,11 +20,11 @@ void mg_timer_free(struct mg_timer *t) {
if (*head) *head = t->next;
}
void mg_timer_poll(int64_t now_ms) {
void mg_timer_poll(uint64_t now_ms) {
// If time goes back (wrapped around), reset timers
struct mg_timer *t, *tmp;
static int64_t oldnow; // Timestamp in a previous invocation
if (oldnow > now_ms) { // If it is wrapped, reset timers
static uint64_t oldnow; // Timestamp in a previous invocation
if (oldnow > now_ms) { // If it is wrapped, reset timers
for (t = g_timers; t != NULL; t = t->next) t->expire = 0;
}
oldnow = now_ms;