X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/d68da9db1b34dbd6f29a0576bc897a9c49e4d7ed..c04c7d0577ceddfe470b6fdcaf727ced91a67d1a:/ev.c diff --git a/ev.c b/ev.c index a80ed9c..83c643a 100644 --- a/ev.c +++ b/ev.c @@ -28,8 +28,30 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EV_EMBED +#ifndef EV_STANDALONE # include "config.h" + +# if HAVE_CLOCK_GETTIME +# define EV_USE_MONOTONIC 1 +# define EV_USE_REALTIME 1 +# endif + +# if HAVE_SELECT && HAVE_SYS_SELECT_H +# define EV_USE_SELECT 1 +# endif + +# if HAVE_POLL && HAVE_POLL_H +# define EV_USE_POLL 1 +# endif + +# if HAVE_EPOLL && HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H +# define EV_USE_EPOLL 1 +# endif + +# if HAVE_KQUEUE && HAVE_WORKING_KQUEUE && HAVE_SYS_EVENT_H && HAVE_SYS_QUEUE_H +# define EV_USE_KQUEUE 1 +# endif + #endif #include @@ -60,8 +82,8 @@ # define EV_USE_SELECT 1 #endif -#ifndef EV_USEV_POLL -# define EV_USEV_POLL 0 /* poll is usually slower than select, and not as well tested */ +#ifndef EV_USE_POLL +# define EV_USE_POLL 0 /* poll is usually slower than select, and not as well tested */ #endif #ifndef EV_USE_EPOLL @@ -95,9 +117,7 @@ #define PID_HASHSIZE 16 /* size of pid hash table, must be power of two */ /*#define CLEANUP_INTERVAL 300. /* how often to try to free memory and re-check fds */ -#ifndef EV_EMBED -# include "ev.h" -#endif +#include "ev.h" #if __GNUC__ >= 3 # define expect(expr,value) __builtin_expect ((expr),(value)) @@ -353,7 +373,7 @@ fd_rearm_all (EV_P) if (anfds [fd].events) { anfds [fd].events = 0; - fd_change (fd); + fd_change (EV_A_ fd); } } @@ -413,6 +433,7 @@ static int signalmax; static int sigpipe [2]; static sig_atomic_t volatile gotsig; +static struct ev_io sigev; static void signals_init (ANSIG *base, int count) @@ -480,6 +501,9 @@ siginit (EV_P) #ifndef WIN32 +static struct ev_child *childs [PID_HASHSIZE]; +static struct ev_signal childev; + #ifndef WCONTINUED # define WCONTINUED 0 #endif @@ -524,7 +548,7 @@ childcb (EV_P_ struct ev_signal *sw, int revents) #if EV_USE_EPOLL # include "ev_epoll.c" #endif -#if EV_USEV_POLL +#if EV_USE_POLL # include "ev_poll.c" #endif #if EV_USE_SELECT @@ -592,7 +616,7 @@ loop_init (EV_P_ int methods) #if EV_USE_EPOLL if (!method && (methods & EVMETHOD_EPOLL )) method = epoll_init (EV_A_ methods); #endif -#if EV_USEV_POLL +#if EV_USE_POLL if (!method && (methods & EVMETHOD_POLL )) method = poll_init (EV_A_ methods); #endif #if EV_USE_SELECT @@ -610,7 +634,7 @@ loop_destroy (EV_P) #if EV_USE_EPOLL if (method == EVMETHOD_EPOLL ) epoll_destroy (EV_A); #endif -#if EV_USEV_POLL +#if EV_USE_POLL if (method == EVMETHOD_POLL ) poll_destroy (EV_A); #endif #if EV_USE_SELECT @@ -641,7 +665,7 @@ ev_loop_new (int methods) loop_init (EV_A_ methods); - if (ev_methods (EV_A)) + if (ev_method (EV_A)) return loop; return 0; @@ -728,8 +752,12 @@ ev_default_destroy (void) } void -ev_default_fork (EV_P) +ev_default_fork (void) { +#if EV_MULTIPLICITY + struct ev_loop *loop = default_loop; +#endif + loop_fork (EV_A); ev_io_stop (EV_A_ &sigev); @@ -768,6 +796,8 @@ timers_reify (EV_P) { struct ev_timer *w = timers [0]; + assert (("inactive timer on timer heap detected", ev_is_active (w))); + /* first reschedule or stop timer */ if (w->repeat) { @@ -789,6 +819,8 @@ periodics_reify (EV_P) { struct ev_periodic *w = periodics [0]; + assert (("inactive timer on periodic heap detected", ev_is_active (w))); + /* first reschedule or stop timer */ if (w->interval) {