#include <string.h>
#include <stdlib.h>
-#ifndef HAVE_CLOCK_GETTIME
-#include "compat/clock_gettime.h"
-#endif
-
#include "mgt.h"
#include "mgt_event.h"
#include "miniobj.h"
/*--------------------------------------------------------------------*/
-static double
-ev_now(void)
-{
- double t;
- struct timespec ts;
-
- assert(clock_gettime(CLOCK_MONOTONIC, &ts) == 0);
- t = ts.tv_sec + ts.tv_nsec * 1e-9;
- return (t);
-}
-
-/*--------------------------------------------------------------------*/
-
static void
ev_bh_update(void *priv, void *a, unsigned u)
{
e->magic = EV_MAGIC; /* before binheap_insert() */
if (e->timeout != 0.0) {
- e->__when += ev_now() + e->timeout;
+ e->__when += TIM_mono() + e->timeout;
binheap_insert(evb->binheap, e);
assert(e->__binheap_idx > 0);
} else {
if (e != NULL) {
CHECK_OBJ_NOTNULL(e, EV_MAGIC);
assert(e->__binheap_idx == 1);
- t = ev_now();
+ t = TIM_mono();
if (e->__when <= t)
return (ev_sched_timeout(evb, e, t));
tmo = (int)((e->__when - t) * 1e3);
return (ev_sched_signal(evb));
if (i == 0) {
assert(e != NULL);
- t = ev_now();
+ t = TIM_mono();
if (e->__when <= t)
return (ev_sched_timeout(evb, e, t));
}