--- libev/ev.h 2009/10/20 00:50:31 1.128 +++ libev/ev.h 2010/03/16 00:26:41 1.135 @@ -1,7 +1,7 @@ /* * libev native API header * - * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann + * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- @@ -44,55 +44,95 @@ extern "C" { #endif -typedef double ev_tstamp; +/*****************************************************************************/ + +#ifndef EV_FEATURES +# define EV_FEATURES 0x3f +#endif + +#define EV_FEATURE_CODE ((EV_FEATURES) & 1) +#define EV_FEATURE_DATA ((EV_FEATURES) & 2) +#define EV_FEATURE_API ((EV_FEATURES) & 4) +#define EV_FEATURE_WATCHERS ((EV_FEATURES) & 8) +#define EV_FEATURE_BACKENDS ((EV_FEATURES) & 16) +#define EV_FEATURE_OS ((EV_FEATURES) & 32) /* these priorities are inclusive, higher priorities will be called earlier */ #ifndef EV_MINPRI -# define EV_MINPRI -2 +# define EV_MINPRI (EV_FEATURE_API ? -2 : 0) #endif #ifndef EV_MAXPRI -# define EV_MAXPRI +2 +# define EV_MAXPRI (EV_FEATURE_API ? +2 : 0) #endif #ifndef EV_MULTIPLICITY -# define EV_MULTIPLICITY 1 +# define EV_MULTIPLICITY EV_FEATURE_API #endif #ifndef EV_PERIODIC_ENABLE -# define EV_PERIODIC_ENABLE 1 +# define EV_PERIODIC_ENABLE EV_FEATURE_WATCHERS #endif #ifndef EV_STAT_ENABLE -# define EV_STAT_ENABLE 1 +# define EV_STAT_ENABLE EV_FEATURE_WATCHERS +#endif + +#ifndef EV_PREPARE_ENABLE +# define EV_PREPARE_ENABLE EV_FEATURE_WATCHERS +#endif + +#ifndef EV_CHECK_ENABLE +# define EV_CHECK_ENABLE EV_FEATURE_WATCHERS #endif #ifndef EV_IDLE_ENABLE -# define EV_IDLE_ENABLE 1 +# define EV_IDLE_ENABLE EV_FEATURE_WATCHERS #endif #ifndef EV_FORK_ENABLE -# define EV_FORK_ENABLE 1 +# define EV_FORK_ENABLE EV_FEATURE_WATCHERS #endif -#ifndef EV_EMBED_ENABLE -# define EV_EMBED_ENABLE 1 +#ifndef EV_SIGNAL_ENABLE +# define EV_SIGNAL_ENABLE EV_FEATURE_WATCHERS +#endif + +#ifndef EV_CHILD_ENABLE +# ifdef _WIN32 +# define EV_CHILD_ENABLE 0 +# else +# define EV_CHILD_ENABLE EV_FEATURE_WATCHERS +#endif #endif #ifndef EV_ASYNC_ENABLE -# define EV_ASYNC_ENABLE 1 +# define EV_ASYNC_ENABLE EV_FEATURE_WATCHERS +#endif + +#ifndef EV_EMBED_ENABLE +# define EV_EMBED_ENABLE EV_FEATURE_WATCHERS #endif #ifndef EV_WALK_ENABLE # define EV_WALK_ENABLE 0 /* not yet */ #endif +/*****************************************************************************/ + +#if EV_CHILD_ENABLE && !EV_SIGNAL_ENABLE +# undef EV_SIGNAL_ENABLE +# define EV_SIGNAL_ENABLE 1 +#endif + +/*****************************************************************************/ + +typedef double ev_tstamp; + #ifndef EV_ATOMIC_T # include # define EV_ATOMIC_T sig_atomic_t volatile #endif -/*****************************************************************************/ - #if EV_STAT_ENABLE # ifdef _WIN32 # include @@ -163,7 +203,7 @@ #endif #define EV_VERSION_MAJOR 3 -#define EV_VERSION_MINOR 8 +#define EV_VERSION_MINOR 9 #ifndef EV_CB_DECLARE # define EV_CB_DECLARE(type) void (*cb)(EV_P_ struct type *w, int revents); @@ -406,7 +446,8 @@ #define EVFLAG_FORKCHECK 0x02000000U /* check for a fork in each iteration */ /* debugging/feature disable */ #define EVFLAG_NOINOTIFY 0x00100000U /* do not attempt to use inotify */ -#define EVFLAG_NOSIGFD 0x00200000U /* do not attempt to use signalfd */ +#define EVFLAG_NOSIGFD 0 /* compatibility to pre-3.9 */ +#define EVFLAG_SIGNALFD 0x00200000U /* attempt to use signalfd */ /* method bits to be ored together */ #define EVBACKEND_SELECT 0x00000001U /* about anywhere */ #define EVBACKEND_POLL 0x00000002U /* !win */ @@ -543,7 +584,7 @@ */ void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg); -# if EV_MINIMAL < 2 +# if EV_FEATURE_API unsigned int ev_loop_count (EV_P); /* number of loop iterations */ unsigned int ev_loop_depth (EV_P); /* #ev_loop enters - #ev_loop leaves */ void ev_loop_verify (EV_P); /* abort if loop data corrupted */ @@ -614,7 +655,7 @@ # define ev_set_priority(ev,pri) ((ev), (pri)) #else # define ev_priority(ev) (+(((ev_watcher *)(void *)(ev))->priority)) -# define ev_set_priority(ev,pri) ( (ev_watcher *)(void *)(ev))->priority = (pri) +# define ev_set_priority(ev,pri) ( (ev_watcher *)(void *)(ev))->priority = (pri) #endif #define ev_periodic_at(ev) (+((ev_watcher_time *)(ev))->at) @@ -631,7 +672,9 @@ /* accepts any ev_watcher type */ void ev_feed_event (EV_P_ void *w, int revents); void ev_feed_fd_event (EV_P_ int fd, int revents); +#if EV_SIGNAL_ENABLE void ev_feed_signal_event (EV_P_ int signum); +#endif void ev_invoke (EV_P_ void *w, int revents); int ev_clear_pending (EV_P_ void *w); @@ -652,12 +695,16 @@ #endif /* only supported in the default loop */ +#if EV_SIGNAL_ENABLE void ev_signal_start (EV_P_ ev_signal *w); void ev_signal_stop (EV_P_ ev_signal *w); +#endif /* only supported in the default loop */ +# if EV_CHILD_ENABLE void ev_child_start (EV_P_ ev_child *w); void ev_child_stop (EV_P_ ev_child *w); +# endif # if EV_STAT_ENABLE void ev_stat_start (EV_P_ ev_stat *w); @@ -670,11 +717,15 @@ void ev_idle_stop (EV_P_ ev_idle *w); # endif +#if EV_PREPARE_ENABLE void ev_prepare_start (EV_P_ ev_prepare *w); void ev_prepare_stop (EV_P_ ev_prepare *w); +#endif +#if EV_CHECK_ENABLE void ev_check_start (EV_P_ ev_check *w); void ev_check_stop (EV_P_ ev_check *w); +#endif # if EV_FORK_ENABLE void ev_fork_start (EV_P_ ev_fork *w);