X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/f80233888429b82d548aed2fca59cd324e1b6610..d89bdc728203c12cec56cf6e5284882842f19ca4:/ev.c?ds=inline diff --git a/ev.c b/ev.c index 1aafbec..2c34141 100644 --- a/ev.c +++ b/ev.c @@ -122,6 +122,12 @@ extern "C" { /**/ +/* darwin simply cannot be helped */ +#ifdef __APPLE__ +# undef EV_USE_POLL +# undef EV_USE_KQUEUE +#endif + #ifndef CLOCK_MONOTONIC # undef EV_USE_MONOTONIC # define EV_USE_MONOTONIC 0 @@ -306,7 +312,7 @@ ev_now (EV_P) } #endif -#define array_roundsize(type,n) ((n) | 4 & ~3) +#define array_roundsize(type,n) (((n) | 4) & ~3) #define array_needsize(type,base,cur,cnt,init) \ if (expect_false ((cnt) > cur)) \ @@ -742,14 +748,14 @@ enable_secure (void) #endif } -int +unsigned int ev_method (EV_P) { return method; } static void -loop_init (EV_P_ int methods) +loop_init (EV_P_ unsigned int flags) { if (!method) { @@ -766,24 +772,24 @@ loop_init (EV_P_ int methods) now_floor = mn_now; rtmn_diff = ev_rt_now - mn_now; - if (methods == EVMETHOD_AUTO) - if (!enable_secure () && getenv ("LIBEV_METHODS")) - methods = atoi (getenv ("LIBEV_METHODS")); - else - methods = EVMETHOD_ANY; + if (!(flags & EVFLAG_NOENV) && !enable_secure () && getenv ("LIBEV_FLAGS")) + flags = atoi (getenv ("LIBEV_FLAGS")); + + if (!(flags & 0x0000ffff)) + flags |= 0x0000ffff; method = 0; #if EV_USE_KQUEUE - if (!method && (methods & EVMETHOD_KQUEUE)) method = kqueue_init (EV_A_ methods); + if (!method && (flags & EVMETHOD_KQUEUE)) method = kqueue_init (EV_A_ flags); #endif #if EV_USE_EPOLL - if (!method && (methods & EVMETHOD_EPOLL )) method = epoll_init (EV_A_ methods); + if (!method && (flags & EVMETHOD_EPOLL )) method = epoll_init (EV_A_ flags); #endif #if EV_USE_POLL - if (!method && (methods & EVMETHOD_POLL )) method = poll_init (EV_A_ methods); + if (!method && (flags & EVMETHOD_POLL )) method = poll_init (EV_A_ flags); #endif #if EV_USE_SELECT - if (!method && (methods & EVMETHOD_SELECT)) method = select_init (EV_A_ methods); + if (!method && (flags & EVMETHOD_SELECT)) method = select_init (EV_A_ flags); #endif ev_init (&sigev, sigcb); @@ -855,13 +861,13 @@ loop_fork (EV_P) #if EV_MULTIPLICITY struct ev_loop * -ev_loop_new (int methods) +ev_loop_new (unsigned int flags) { struct ev_loop *loop = (struct ev_loop *)ev_malloc (sizeof (struct ev_loop)); memset (loop, 0, sizeof (struct ev_loop)); - loop_init (EV_A_ methods); + loop_init (EV_A_ flags); if (ev_method (EV_A)) return loop; @@ -889,7 +895,7 @@ struct ev_loop * #else int #endif -ev_default_loop (int methods) +ev_default_loop (unsigned int flags) { if (sigpipe [0] == sigpipe [1]) if (pipe (sigpipe)) @@ -903,7 +909,7 @@ ev_default_loop (int methods) default_loop = 1; #endif - loop_init (EV_A_ methods); + loop_init (EV_A_ flags); if (ev_method (EV_A)) { @@ -1027,8 +1033,7 @@ periodics_reify (EV_P) /* first reschedule or stop timer */ if (w->reschedule_cb) { - ev_tstamp at = ((WT)w)->at = w->reschedule_cb (w, ev_rt_now + 0.0001); - + ((WT)w)->at = w->reschedule_cb (w, ev_rt_now + 0.0001); assert (("ev_periodic reschedule callback returned time in the past", ((WT)w)->at > ev_rt_now)); downheap ((WT *)periodics, periodiccnt, 0); } @@ -1379,7 +1384,10 @@ ev_timer_again (EV_P_ struct ev_timer *w) ev_timer_stop (EV_A_ w); } else if (w->repeat) - ev_timer_start (EV_A_ w); + { + w->at = w->repeat; + ev_timer_start (EV_A_ w); + } } #if EV_PERIODICS