… | |
… | |
69 | # define EV_DEFAULT_A |
69 | # define EV_DEFAULT_A |
70 | # define EV_DEFAULT_A_ |
70 | # define EV_DEFAULT_A_ |
71 | #endif |
71 | #endif |
72 | |
72 | |
73 | /* eventmask, revents, events... */ |
73 | /* eventmask, revents, events... */ |
74 | #define EV_UNDEF -1 /* guaranteed to be invalid */ |
74 | #define EV_UNDEF -1L /* guaranteed to be invalid */ |
75 | #define EV_NONE 0x00 |
75 | #define EV_NONE 0x00L |
76 | #define EV_READ 0x01 /* io only */ |
76 | #define EV_READ 0x01L /* io only */ |
77 | #define EV_WRITE 0x02 /* io only */ |
77 | #define EV_WRITE 0x02L /* io only */ |
78 | #define EV_TIMEOUT 0x000100 /* timer only */ |
78 | #define EV_TIMEOUT 0x000100L /* timer only */ |
79 | #define EV_PERIODIC 0x000200 /* periodic timer only */ |
79 | #define EV_PERIODIC 0x000200L /* periodic timer only */ |
80 | #define EV_SIGNAL 0x000400 /* signal only */ |
80 | #define EV_SIGNAL 0x000400L /* signal only */ |
81 | #define EV_IDLE 0x000800 /* idle only */ |
81 | #define EV_IDLE 0x000800L /* idle only */ |
82 | #define EV_CHECK 0x001000 /* check only */ |
82 | #define EV_CHECK 0x001000L /* check only */ |
83 | #define EV_PREPARE 0x002000 /* prepare only */ |
83 | #define EV_PREPARE 0x002000L /* prepare only */ |
84 | #define EV_CHILD 0x004000 /* child/pid only */ |
84 | #define EV_CHILD 0x004000L /* child/pid only */ |
85 | #define EV_ERROR 0x800000 /* sent when an error occurs */ |
85 | #define EV_ERROR 0x800000L /* sent when an error occurs */ |
86 | |
86 | |
87 | /* can be used to add custom fields to all watchers, while losing binary compatibility */ |
87 | /* can be used to add custom fields to all watchers, while losing binary compatibility */ |
88 | #ifndef EV_COMMON |
88 | #ifndef EV_COMMON |
89 | # define EV_COMMON void *data; |
89 | # define EV_COMMON void *data; |
90 | #endif |
90 | #endif |
… | |
… | |
201 | struct ev_check |
201 | struct ev_check |
202 | { |
202 | { |
203 | EV_WATCHER (ev_check) |
203 | EV_WATCHER (ev_check) |
204 | }; |
204 | }; |
205 | |
205 | |
206 | /* invoked when sigchld is received and waitpid indicates the givne pid */ |
206 | /* invoked when sigchld is received and waitpid indicates the given pid */ |
207 | /* revent EV_CHILD */ |
207 | /* revent EV_CHILD */ |
208 | /* does not support priorities */ |
208 | /* does not support priorities */ |
209 | struct ev_child |
209 | struct ev_child |
210 | { |
210 | { |
211 | EV_WATCHER_LIST (ev_child) |
211 | EV_WATCHER_LIST (ev_child) |
… | |
… | |
229 | struct ev_check check; |
229 | struct ev_check check; |
230 | struct ev_signal signal; |
230 | struct ev_signal signal; |
231 | struct ev_child child; |
231 | struct ev_child child; |
232 | }; |
232 | }; |
233 | |
233 | |
234 | #define EVMETHOD_AUTO 0 /* consults environment */ |
234 | /* bits for ev_default_loop and ev_loop_new */ |
235 | #define EVMETHOD_SELECT 1 |
235 | /* the default */ |
236 | #define EVMETHOD_POLL 2 |
236 | #define EVFLAG_AUTO 0x00000000UL /* not quite a mask */ |
237 | #define EVMETHOD_EPOLL 4 |
237 | /* flag bits */ |
238 | #define EVMETHOD_KQUEUE 8 |
238 | #define EVFLAG_NOENV 0x01000000UL /* do NOT consult environment */ |
239 | #define EVMETHOD_DEVPOLL 16 /* NYI */ |
239 | /* method bits to be ored together */ |
240 | #define EVMETHOD_PORT 32 /* NYI */ |
240 | #define EVBACKEND_SELECT 0x00000001UL /* about anywhere */ |
241 | #define EVMETHOD_WIN32 64 /* NYI */ |
241 | #define EVBACKEND_POLL 0x00000002UL /* !win */ |
242 | #define EVMETHOD_ANY ~0 /* any method, do not consult env */ |
242 | #define EVBACKEND_EPOLL 0x00000004UL /* linux */ |
|
|
243 | #define EVBACKEND_KQUEUE 0x00000008UL /* bsd */ |
|
|
244 | #define EVBACKEND_DEVPOLL 0x00000010UL /* solaris 8 */ /* NYI */ |
|
|
245 | #define EVBACKEND_PORT 0x00000020UL /* solaris 10 */ |
243 | |
246 | |
244 | #if EV_PROTOTYPES |
247 | #if EV_PROTOTYPES |
245 | int ev_version_major (void); |
248 | int ev_version_major (void); |
246 | int ev_version_minor (void); |
249 | int ev_version_minor (void); |
|
|
250 | |
|
|
251 | unsigned int ev_supported_backends (void); |
|
|
252 | unsigned int ev_recommended_backends (void); |
247 | |
253 | |
248 | ev_tstamp ev_time (void); |
254 | ev_tstamp ev_time (void); |
249 | |
255 | |
250 | /* Sets the allocation function to use, works like realloc. |
256 | /* Sets the allocation function to use, works like realloc. |
251 | * It is used to allocate and free memory. |
257 | * It is used to allocate and free memory. |
… | |
… | |
262 | void ev_set_syserr_cb (void (*cb)(const char *msg)); |
268 | void ev_set_syserr_cb (void (*cb)(const char *msg)); |
263 | |
269 | |
264 | # if EV_MULTIPLICITY |
270 | # if EV_MULTIPLICITY |
265 | /* the default loop is the only one that handles signals and child watchers */ |
271 | /* the default loop is the only one that handles signals and child watchers */ |
266 | /* you can call this as often as you like */ |
272 | /* you can call this as often as you like */ |
267 | struct ev_loop *ev_default_loop (int methods); /* returns default loop */ |
273 | static struct ev_loop * |
|
|
274 | ev_default_loop (unsigned int flags) |
|
|
275 | { |
|
|
276 | extern struct ev_loop *ev_default_loop_ptr; |
|
|
277 | extern struct ev_loop *ev_default_loop_init (unsigned int flags); |
|
|
278 | |
|
|
279 | if (!ev_default_loop_ptr) |
|
|
280 | ev_default_loop_init (flags); |
|
|
281 | |
|
|
282 | return ev_default_loop_ptr; |
|
|
283 | } |
268 | |
284 | |
269 | /* create and destroy alternative loops that don't handle signals */ |
285 | /* create and destroy alternative loops that don't handle signals */ |
270 | struct ev_loop *ev_loop_new (int methods); |
286 | struct ev_loop *ev_loop_new (unsigned int flags); |
271 | void ev_loop_destroy (EV_P); |
287 | void ev_loop_destroy (EV_P); |
272 | void ev_loop_fork (EV_P); |
288 | void ev_loop_fork (EV_P); |
273 | |
289 | |
274 | ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */ |
290 | ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */ |
275 | |
291 | |
276 | # else |
292 | # else |
277 | |
293 | |
278 | int ev_default_loop (int methods); /* returns true when successful */ |
294 | int ev_default_loop (unsigned int flags); /* returns true when successful */ |
279 | |
295 | |
280 | static ev_tstamp |
296 | static ev_tstamp |
281 | ev_now (void) |
297 | ev_now (void) |
282 | { |
298 | { |
283 | extern ev_tstamp ev_rt_now; |
299 | extern ev_tstamp ev_rt_now; |
… | |
… | |
291 | /* if you create alternative loops you have to call ev_loop_fork on them */ |
307 | /* if you create alternative loops you have to call ev_loop_fork on them */ |
292 | /* you can call it in either the parent or the child */ |
308 | /* you can call it in either the parent or the child */ |
293 | /* you can actually call it at any time, anywhere :) */ |
309 | /* you can actually call it at any time, anywhere :) */ |
294 | void ev_default_fork (void); |
310 | void ev_default_fork (void); |
295 | |
311 | |
296 | int ev_method (EV_P); |
312 | unsigned int ev_backend (EV_P); |
297 | #endif |
313 | #endif |
298 | |
314 | |
299 | #define EVLOOP_NONBLOCK 1 /* do not block/wait */ |
315 | #define EVLOOP_NONBLOCK 1 /* do not block/wait */ |
300 | #define EVLOOP_ONESHOT 2 /* block *once* only */ |
316 | #define EVLOOP_ONESHOT 2 /* block *once* only */ |
301 | #define EVUNLOOP_ONCE 1 /* unloop once */ |
317 | #define EVUNLOOP_ONE 1 /* unloop once */ |
302 | #define EVUNLOOP_ALL 2 /* unloop all loops */ |
318 | #define EVUNLOOP_ALL 2 /* unloop all loops */ |
303 | |
319 | |
304 | #if EV_PROTOTYPES |
320 | #if EV_PROTOTYPES |
305 | void ev_loop (EV_P_ int flags); |
321 | void ev_loop (EV_P_ int flags); |
306 | void ev_unloop (EV_P_ int how); /* set to 1 to break out of event loop, set to 2 to break out of all event loops */ |
322 | void ev_unloop (EV_P_ int how); /* set to 1 to break out of event loop, set to 2 to break out of all event loops */ |