Skip to content
2 changes: 1 addition & 1 deletion cpu/mips32r2_common/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int gettimeofday(struct timeval *__restrict __p, void *__restrict __tz)
(void)__tz;

uint64_t now = counter * US_PER_MS;
__p->tv_sec = div_u64_by_1000000(now);
__p->tv_sec = div_64(now, 1000000UL);
__p->tv_usec = now - (__p->tv_sec * US_PER_SEC);

return 0;
Expand Down
8 changes: 7 additions & 1 deletion sys/evtimer/evtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,14 @@ static uint32_t _get_offset(xtimer_t *timer)
}
else {
target_us -= now_us;

/* add half of 125 so integer division rounds to nearest */
return div_u64_by_125((target_us >> 3) + 62);
target_us = (target_us >> 3) + 62;

/* a higher value would overflow the result type */
assert(target_us <= 536870911999LLU);

return (uint32_t)div_64(target_us, 125);
}
}

Expand Down
Loading