… | |
… | |
8 | #include "EV/EVAPI.h" |
8 | #include "EV/EVAPI.h" |
9 | |
9 | |
10 | #include "libev/ev.c" |
10 | #include "libev/ev.c" |
11 | #include "libev/event.h" |
11 | #include "libev/event.h" |
12 | #include "libev/event.c" |
12 | #include "libev/event.c" |
|
|
13 | #define DNS_USE_GETTIMEOFDAY_FOR_ID 1 |
|
|
14 | #define HAVE_STRUCT_IN6_ADDR 1 |
|
|
15 | #undef HAVE_STRTOK_R |
|
|
16 | #undef strtok_r |
|
|
17 | #define strtok_r fake_strtok_r |
13 | #include "libev/evdns.c" |
18 | #include "libev/evdns.c" |
14 | |
19 | |
15 | typedef int Signal; |
20 | typedef int Signal; |
16 | |
21 | |
17 | static struct EVAPI evapi; |
22 | static struct EVAPI evapi; |
… | |
… | |
25 | *stash_idle, |
30 | *stash_idle, |
26 | *stash_prepare, |
31 | *stash_prepare, |
27 | *stash_check, |
32 | *stash_check, |
28 | *stash_child; |
33 | *stash_child; |
29 | |
34 | |
|
|
35 | #ifndef SIG_SIZE |
|
|
36 | /* kudos to Slaven Rezic for the idea */ |
|
|
37 | static char sig_size [] = { SIG_NUM }; |
|
|
38 | # define SIG_SIZE (sizeof (sig_size) + 1) |
|
|
39 | #endif |
|
|
40 | |
30 | static int |
41 | static int |
31 | sv_signum (SV *sig) |
42 | sv_signum (SV *sig) |
32 | { |
43 | { |
33 | int signum; |
44 | int signum; |
34 | |
45 | |
… | |
… | |
131 | |
142 | |
132 | PUSHMARK (SP); |
143 | PUSHMARK (SP); |
133 | EXTEND (SP, 2); |
144 | EXTEND (SP, 2); |
134 | PUSHs (sv_self); |
145 | PUSHs (sv_self); |
135 | PUSHs (sv_events); |
146 | PUSHs (sv_events); |
136 | |
|
|
137 | if (revents & EV_CHILD) |
|
|
138 | XPUSHs (sv_status = newSViv (((struct ev_child *)w)->status)); |
|
|
139 | |
147 | |
140 | PUTBACK; |
148 | PUTBACK; |
141 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
149 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
142 | SP = PL_stack_base + mark; PUTBACK; |
150 | SP = PL_stack_base + mark; PUTBACK; |
143 | |
151 | |
… | |
… | |
279 | /* the poor man's shared library emulator */ |
287 | /* the poor man's shared library emulator */ |
280 | evapi.ver = EV_API_VERSION; |
288 | evapi.ver = EV_API_VERSION; |
281 | evapi.rev = EV_API_REVISION; |
289 | evapi.rev = EV_API_REVISION; |
282 | evapi.sv_fileno = sv_fileno; |
290 | evapi.sv_fileno = sv_fileno; |
283 | evapi.sv_signum = sv_signum; |
291 | evapi.sv_signum = sv_signum; |
284 | evapi.now = &ev_now; |
292 | evapi.now = ev_now; |
285 | evapi.method = &ev_method; |
293 | evapi.method = ev_method; |
286 | evapi.loop_done = &ev_loop_done; |
294 | evapi.unloop = ev_unloop; |
287 | evapi.time = ev_time; |
295 | evapi.time = ev_time; |
288 | evapi.loop = ev_loop; |
296 | evapi.loop = ev_loop; |
289 | evapi.once = ev_once; |
297 | evapi.once = ev_once; |
290 | evapi.io_start = ev_io_start; |
298 | evapi.io_start = ev_io_start; |
291 | evapi.io_stop = ev_io_stop; |
299 | evapi.io_stop = ev_io_stop; |
… | |
… | |
311 | |
319 | |
312 | pthread_atfork (ev_fork_prepare, ev_fork_parent, ev_fork_child); |
320 | pthread_atfork (ev_fork_prepare, ev_fork_parent, ev_fork_child); |
313 | } |
321 | } |
314 | |
322 | |
315 | NV ev_now () |
323 | NV ev_now () |
316 | CODE: |
|
|
317 | RETVAL = ev_now; |
|
|
318 | OUTPUT: |
|
|
319 | RETVAL |
|
|
320 | |
324 | |
321 | int ev_method () |
325 | int ev_method () |
322 | CODE: |
|
|
323 | RETVAL = ev_method; |
|
|
324 | OUTPUT: |
|
|
325 | RETVAL |
|
|
326 | |
326 | |
327 | NV ev_time () |
327 | NV ev_time () |
328 | |
328 | |
329 | void ev_init (int methods = EVMETHOD_AUTO) |
329 | int ev_init (int methods = EVMETHOD_AUTO) |
330 | |
330 | |
331 | void ev_loop (int flags = 0) |
331 | void ev_loop (int flags = 0) |
332 | |
332 | |
333 | void ev_loop_done (int value = 1) |
333 | void ev_unloop (int how = 1) |
334 | CODE: |
|
|
335 | ev_loop_done = value; |
|
|
336 | |
334 | |
337 | struct ev_io *io (SV *fh, int events, SV *cb) |
335 | struct ev_io *io (SV *fh, int events, SV *cb) |
338 | ALIAS: |
336 | ALIAS: |
339 | io_ns = 1 |
337 | io_ns = 1 |
340 | CODE: |
338 | CODE: |
… | |
… | |
416 | |
414 | |
417 | struct ev_child *child (int pid, SV *cb) |
415 | struct ev_child *child (int pid, SV *cb) |
418 | ALIAS: |
416 | ALIAS: |
419 | check_ns = 1 |
417 | check_ns = 1 |
420 | CODE: |
418 | CODE: |
421 | RETVAL = e_new (sizeof (struct ev_check), cb); |
419 | RETVAL = e_new (sizeof (struct ev_child), cb); |
422 | ev_child_set (RETVAL, pid); |
420 | ev_child_set (RETVAL, pid); |
423 | if (!ix) ev_child_start (RETVAL); |
421 | if (!ix) ev_child_start (RETVAL); |
424 | OUTPUT: |
422 | OUTPUT: |
425 | RETVAL |
423 | RETVAL |
426 | |
424 | |
… | |
… | |
713 | } |
711 | } |
714 | OUTPUT: |
712 | OUTPUT: |
715 | RETVAL |
713 | RETVAL |
716 | |
714 | |
717 | |
715 | |
718 | int status (struct ev_child *w) |
716 | int rstatus (struct ev_child *w) |
|
|
717 | ALIAS: |
|
|
718 | rpid = 1 |
719 | CODE: |
719 | CODE: |
720 | RETVAL = w->status; |
720 | RETVAL = ix ? w->rpid : w->rstatus; |
721 | OUTPUT: |
721 | OUTPUT: |
722 | RETVAL |
722 | RETVAL |
723 | |
723 | |
724 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
724 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
725 | |
725 | |