… | |
… | |
46 | # define EV_CPP(x) |
46 | # define EV_CPP(x) |
47 | #endif |
47 | #endif |
48 | |
48 | |
49 | #define EV_THROW EV_CPP(throw()) |
49 | #define EV_THROW EV_CPP(throw()) |
50 | |
50 | |
|
|
51 | /* apple's proprietary clang fork errors out with exception specifications */ |
|
|
52 | /* in all sorts of places, so let's not even bother with them */ |
|
|
53 | /* users are strongly advised to install clang or gcc */ |
|
|
54 | #if __APPLE__ && __clang__ |
|
|
55 | # undef EV_THROW |
|
|
56 | # define EV_THROW |
|
|
57 | #endif |
|
|
58 | |
51 | EV_CPP(extern "C" {) |
59 | EV_CPP(extern "C" {) |
52 | |
60 | |
53 | /*****************************************************************************/ |
61 | /*****************************************************************************/ |
54 | |
62 | |
55 | /* pre-4.0 compatibility */ |
63 | /* pre-4.0 compatibility */ |
… | |
… | |
203 | #endif |
211 | #endif |
204 | |
212 | |
205 | /*****************************************************************************/ |
213 | /*****************************************************************************/ |
206 | |
214 | |
207 | #define EV_VERSION_MAJOR 4 |
215 | #define EV_VERSION_MAJOR 4 |
208 | #define EV_VERSION_MINOR 11 |
216 | #define EV_VERSION_MINOR 18 |
209 | |
217 | |
210 | /* eventmask, revents, events... */ |
218 | /* eventmask, revents, events... */ |
211 | enum { |
219 | enum { |
212 | EV_UNDEF = 0xFFFFFFFF, /* guaranteed to be invalid */ |
220 | EV_UNDEF = (int)0xFFFFFFFF, /* guaranteed to be invalid */ |
213 | EV_NONE = 0x00, /* no events */ |
221 | EV_NONE = 0x00, /* no events */ |
214 | EV_READ = 0x01, /* ev_io detected read will not block */ |
222 | EV_READ = 0x01, /* ev_io detected read will not block */ |
215 | EV_WRITE = 0x02, /* ev_io detected write will not block */ |
223 | EV_WRITE = 0x02, /* ev_io detected write will not block */ |
216 | EV__IOFDSET = 0x80, /* internal use only */ |
224 | EV__IOFDSET = 0x80, /* internal use only */ |
217 | EV_IO = EV_READ, /* alias for type-detection */ |
225 | EV_IO = EV_READ, /* alias for type-detection */ |
218 | EV_TIMER = 0x00000100, /* timer timed out */ |
226 | EV_TIMER = 0x00000100, /* timer timed out */ |
219 | #if EV_COMPAT3 |
227 | #if EV_COMPAT3 |
220 | EV_TIMEOUT = EV_TIMER, /* pre 4.0 API compatibility */ |
228 | EV_TIMEOUT = EV_TIMER, /* pre 4.0 API compatibility */ |
221 | #endif |
229 | #endif |
222 | EV_PERIODIC = 0x00000200, /* periodic timer timed out */ |
230 | EV_PERIODIC = 0x00000200, /* periodic timer timed out */ |
223 | EV_SIGNAL = 0x00000400, /* signal was received */ |
231 | EV_SIGNAL = 0x00000400, /* signal was received */ |
224 | EV_CHILD = 0x00000800, /* child/pid had status change */ |
232 | EV_CHILD = 0x00000800, /* child/pid had status change */ |
225 | EV_STAT = 0x00001000, /* stat data changed */ |
233 | EV_STAT = 0x00001000, /* stat data changed */ |
226 | EV_IDLE = 0x00002000, /* event loop is idling */ |
234 | EV_IDLE = 0x00002000, /* event loop is idling */ |
227 | EV_PREPARE = 0x00004000, /* event loop about to poll */ |
235 | EV_PREPARE = 0x00004000, /* event loop about to poll */ |
228 | EV_CHECK = 0x00008000, /* event loop finished poll */ |
236 | EV_CHECK = 0x00008000, /* event loop finished poll */ |
229 | EV_EMBED = 0x00010000, /* embedded event loop needs sweep */ |
237 | EV_EMBED = 0x00010000, /* embedded event loop needs sweep */ |
230 | EV_FORK = 0x00020000, /* event loop resumed in child */ |
238 | EV_FORK = 0x00020000, /* event loop resumed in child */ |
231 | EV_CLEANUP = 0x00040000, /* event loop resumed in child */ |
239 | EV_CLEANUP = 0x00040000, /* event loop resumed in child */ |
232 | EV_ASYNC = 0x00080000, /* async intra-loop signal */ |
240 | EV_ASYNC = 0x00080000, /* async intra-loop signal */ |
233 | EV_CUSTOM = 0x01000000, /* for use by user code */ |
241 | EV_CUSTOM = 0x01000000, /* for use by user code */ |
234 | EV_ERROR = 0x80000000 /* sent when an error occurs */ |
242 | EV_ERROR = (int)0x80000000 /* sent when an error occurs */ |
235 | }; |
243 | }; |
236 | |
244 | |
237 | /* can be used to add custom fields to all watchers, while losing binary compatibility */ |
245 | /* can be used to add custom fields to all watchers, while losing binary compatibility */ |
238 | #ifndef EV_COMMON |
246 | #ifndef EV_COMMON |
239 | # define EV_COMMON void *data; |
247 | # define EV_COMMON void *data; |
… | |
… | |
593 | } |
601 | } |
594 | |
602 | |
595 | #endif /* multiplicity */ |
603 | #endif /* multiplicity */ |
596 | |
604 | |
597 | /* destroy event loops, also works for the default loop */ |
605 | /* destroy event loops, also works for the default loop */ |
598 | EV_API_DECL void ev_loop_destroy (EV_P) EV_THROW; |
606 | EV_API_DECL void ev_loop_destroy (EV_P); |
599 | |
607 | |
600 | /* this needs to be called after fork, to duplicate the loop */ |
608 | /* this needs to be called after fork, to duplicate the loop */ |
601 | /* when you want to re-use it in the child */ |
609 | /* when you want to re-use it in the child */ |
602 | /* you can call it in either the parent or the child */ |
610 | /* you can call it in either the parent or the child */ |
603 | /* you can actually call it at any time, anywhere :) */ |
611 | /* you can actually call it at any time, anywhere :) */ |
… | |
… | |
656 | EV_API_DECL void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) EV_THROW; /* sleep at least this time, default 0 */ |
664 | EV_API_DECL void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) EV_THROW; /* sleep at least this time, default 0 */ |
657 | |
665 | |
658 | /* advanced stuff for threading etc. support, see docs */ |
666 | /* advanced stuff for threading etc. support, see docs */ |
659 | EV_API_DECL void ev_set_userdata (EV_P_ void *data) EV_THROW; |
667 | EV_API_DECL void ev_set_userdata (EV_P_ void *data) EV_THROW; |
660 | EV_API_DECL void *ev_userdata (EV_P) EV_THROW; |
668 | EV_API_DECL void *ev_userdata (EV_P) EV_THROW; |
|
|
669 | typedef void (*ev_loop_callback)(EV_P); |
661 | EV_API_DECL void ev_set_invoke_pending_cb (EV_P_ void (*invoke_pending_cb)(EV_P)) EV_THROW; |
670 | EV_API_DECL void ev_set_invoke_pending_cb (EV_P_ ev_loop_callback invoke_pending_cb) EV_THROW; |
662 | EV_API_DECL void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P), void (*acquire)(EV_P) EV_THROW) EV_THROW; |
671 | EV_API_DECL void ev_set_loop_release_cb (EV_P_ ev_loop_callback EV_THROW release, ev_loop_callback EV_THROW acquire) EV_THROW; |
663 | |
672 | |
664 | EV_API_DECL unsigned int ev_pending_count (EV_P) EV_THROW; /* number of pending events, if any */ |
673 | EV_API_DECL unsigned int ev_pending_count (EV_P) EV_THROW; /* number of pending events, if any */ |
665 | EV_API_DECL void ev_invoke_pending (EV_P); /* invoke all pending watchers */ |
674 | EV_API_DECL void ev_invoke_pending (EV_P); /* invoke all pending watchers */ |
666 | |
675 | |
667 | /* |
676 | /* |
… | |
… | |
728 | #ifndef ev_set_cb |
737 | #ifndef ev_set_cb |
729 | # define ev_set_cb(ev,cb_) ev_cb (ev) = (cb_) |
738 | # define ev_set_cb(ev,cb_) ev_cb (ev) = (cb_) |
730 | #endif |
739 | #endif |
731 | |
740 | |
732 | /* stopping (enabling, adding) a watcher does nothing if it is already running */ |
741 | /* stopping (enabling, adding) a watcher does nothing if it is already running */ |
733 | /* stopping (disabling, deleting) a watcher does nothing unless its already running */ |
742 | /* stopping (disabling, deleting) a watcher does nothing unless it's already running */ |
734 | #if EV_PROTOTYPES |
743 | #if EV_PROTOTYPES |
735 | |
744 | |
736 | /* feeds an event into a watcher as if the event actually occurred */ |
745 | /* feeds an event into a watcher as if the event actually occurred */ |
737 | /* accepts any ev_watcher type */ |
746 | /* accepts any ev_watcher type */ |
738 | EV_API_DECL void ev_feed_event (EV_P_ void *w, int revents) EV_THROW; |
747 | EV_API_DECL void ev_feed_event (EV_P_ void *w, int revents) EV_THROW; |