static struct fd **fds = NULL;
static LIST_HEAD(closing);
static LIST_HEAD(always);
+static struct timemono (*nowfn)(void) = time_mono;
+
+struct timemono (*io_time_override(struct timemono (*now)(void)))(void)
+{
+ struct timemono (*old)(void) = nowfn;
+ nowfn = now;
+ return old;
+}
static bool add_fd(struct fd *fd, short events)
{
assert(num_waiting);
if (timers) {
- struct timeabs now, first;
+ struct timemono now, first;
- now = time_now();
+ now = nowfn();
/* Call functions for expired timers. */
*expired = timers_expire(timers, now);
/* Now figure out how long to wait for the next one. */
if (timer_earliest(timers, &first)) {
uint64_t next;
- next = time_to_msec(time_between(first, now));
+ next = time_to_msec(timemono_between(first, now));
if (next < INT_MAX)
ms_timeout = next;
else