… | |
… | |
9 | |
9 | |
10 | /* fix perl api breakage */ |
10 | /* fix perl api breakage */ |
11 | #undef signal |
11 | #undef signal |
12 | #undef sigaction |
12 | #undef sigaction |
13 | |
13 | |
|
|
14 | #define EV_USE_MONOTONIC 1 |
|
|
15 | #define EV_USE_REALTIME 1 |
14 | #define EV_SELECT_USE_WIN32_HANDLES 0 |
16 | #define EV_SELECT_IS_WINSOCKET 0 |
|
|
17 | #ifdef _WIN32 |
15 | #define EV_SELECT_USE_FD_SET 0 |
18 | # define EV_SELECT_USE_FD_SET 0 |
|
|
19 | # define NFDBITS PERL_NFDBITS |
|
|
20 | # define fd_mask Perl_fd_mask |
|
|
21 | #endif |
16 | /* due to bugs in OS X we have to use libev/ explicitly here */ |
22 | /* due to bugs in OS X we have to use libev/ explicitly here */ |
17 | #include "libev/ev.c" |
23 | #include "libev/ev.c" |
18 | #include "event.c" |
24 | #include "event.c" |
19 | |
25 | |
20 | #ifndef WIN32 |
26 | #ifndef _WIN32 |
21 | #define DNS_USE_GETTIMEOFDAY_FOR_ID 1 |
27 | #define DNS_USE_GETTIMEOFDAY_FOR_ID 1 |
22 | #if !defined (WIN32) && !defined(__CYGWIN__) |
28 | #if !defined (WIN32) && !defined(__CYGWIN__) |
23 | # define HAVE_STRUCT_IN6_ADDR 1 |
29 | # define HAVE_STRUCT_IN6_ADDR 1 |
24 | #endif |
30 | #endif |
25 | #undef HAVE_STRTOK_R |
31 | #undef HAVE_STRTOK_R |
26 | #undef strtok_r |
32 | #undef strtok_r |
27 | #define strtok_r fake_strtok_r |
33 | #define strtok_r fake_strtok_r |
|
|
34 | #include "evdns.h" |
28 | #include "evdns.c" |
35 | #include "evdns.c" |
29 | #endif |
36 | #endif |
30 | |
37 | |
31 | #ifndef WIN32 |
38 | #ifndef _WIN32 |
32 | # include <pthread.h> |
39 | # include <pthread.h> |
33 | #endif |
40 | #endif |
34 | |
41 | |
35 | typedef int Signal; |
42 | typedef int Signal; |
36 | |
43 | |
… | |
… | |
100 | SvPOK_only (self); |
107 | SvPOK_only (self); |
101 | SvCUR_set (self, size); |
108 | SvCUR_set (self, size); |
102 | |
109 | |
103 | w = (struct ev_watcher *)SvPVX (self); |
110 | w = (struct ev_watcher *)SvPVX (self); |
104 | |
111 | |
105 | ev_watcher_init (w, e_cb); |
112 | ev_init (w, e_cb); |
106 | |
113 | |
107 | w->data = 0; |
114 | w->data = 0; |
108 | w->fh = 0; |
115 | w->fh = 0; |
109 | w->cb_sv = newSVsv (cb_sv); |
116 | w->cb_sv = newSVsv (cb_sv); |
110 | w->self = self; |
117 | w->self = self; |
… | |
… | |
162 | PUSHs (sv_self); |
169 | PUSHs (sv_self); |
163 | PUSHs (sv_events); |
170 | PUSHs (sv_events); |
164 | |
171 | |
165 | PUTBACK; |
172 | PUTBACK; |
166 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
173 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
167 | SP = PL_stack_base + mark; PUTBACK; |
|
|
168 | |
174 | |
169 | SvREFCNT_dec (sv_self); |
175 | SvREFCNT_dec (sv_self); |
170 | SvREFCNT_dec (sv_status); |
176 | SvREFCNT_dec (sv_status); |
171 | |
177 | |
172 | if (sv_events_cache) |
178 | if (sv_events_cache) |
… | |
… | |
177 | if (SvTRUE (ERRSV)) |
183 | if (SvTRUE (ERRSV)) |
178 | { |
184 | { |
179 | PUSHMARK (SP); |
185 | PUSHMARK (SP); |
180 | PUTBACK; |
186 | PUTBACK; |
181 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
187 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
182 | SP = PL_stack_base + mark; PUTBACK; |
|
|
183 | } |
188 | } |
|
|
189 | |
|
|
190 | SP = PL_stack_base + mark; |
|
|
191 | PUTBACK; |
184 | } |
192 | } |
185 | |
193 | |
186 | static ev_tstamp |
194 | static ev_tstamp |
187 | e_periodic_cb (struct ev_periodic *w, ev_tstamp now) |
195 | e_periodic_cb (struct ev_periodic *w, ev_tstamp now) |
188 | { |
196 | { |
… | |
… | |
227 | } |
235 | } |
228 | |
236 | |
229 | ///////////////////////////////////////////////////////////////////////////// |
237 | ///////////////////////////////////////////////////////////////////////////// |
230 | // DNS |
238 | // DNS |
231 | |
239 | |
232 | #ifndef WIN32 |
240 | #ifndef _WIN32 |
233 | static void |
241 | static void |
234 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
242 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
235 | { |
243 | { |
236 | dSP; |
244 | dSP; |
237 | SV *cb = (SV *)arg; |
245 | SV *cb = (SV *)arg; |
… | |
… | |
315 | const_iv (EV_, CHECK) |
323 | const_iv (EV_, CHECK) |
316 | const_iv (EV_, ERROR) |
324 | const_iv (EV_, ERROR) |
317 | |
325 | |
318 | const_iv (EV, LOOP_ONESHOT) |
326 | const_iv (EV, LOOP_ONESHOT) |
319 | const_iv (EV, LOOP_NONBLOCK) |
327 | const_iv (EV, LOOP_NONBLOCK) |
|
|
328 | const_iv (EV, UNLOOP_ONE) |
|
|
329 | const_iv (EV, UNLOOP_ALL) |
320 | |
330 | |
321 | const_iv (EV, METHOD_AUTO) |
|
|
322 | const_iv (EV, METHOD_SELECT) |
331 | const_iv (EV, METHOD_SELECT) |
323 | const_iv (EV, METHOD_POLL) |
332 | const_iv (EV, METHOD_POLL) |
324 | const_iv (EV, METHOD_EPOLL) |
333 | const_iv (EV, METHOD_EPOLL) |
325 | const_iv (EV, METHOD_KQUEUE) |
334 | const_iv (EV, METHOD_KQUEUE) |
326 | const_iv (EV, METHOD_DEVPOLL) |
335 | const_iv (EV, METHOD_DEVPOLL) |
327 | const_iv (EV, METHOD_PORT) |
336 | const_iv (EV, METHOD_PORT) |
328 | const_iv (EV, METHOD_ANY) |
337 | const_iv (EV, FLAG_AUTO) |
|
|
338 | const_iv (EV, FLAG_NOENV) |
329 | }; |
339 | }; |
330 | |
340 | |
331 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
341 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
332 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
342 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
333 | |
343 | |
… | |
… | |
375 | evapi.child_stop = ev_child_stop; |
385 | evapi.child_stop = ev_child_stop; |
376 | |
386 | |
377 | sv_setiv (sv, (IV)&evapi); |
387 | sv_setiv (sv, (IV)&evapi); |
378 | SvREADONLY_on (sv); |
388 | SvREADONLY_on (sv); |
379 | } |
389 | } |
380 | #ifndef WIN32 |
390 | #ifndef _WIN32 |
381 | pthread_atfork (0, 0, ev_default_fork); |
391 | pthread_atfork (0, 0, ev_default_fork); |
382 | #endif |
392 | #endif |
383 | } |
393 | } |
384 | |
394 | |
385 | NV ev_now () |
395 | NV ev_now () |
386 | |
396 | |
387 | int ev_method () |
397 | int ev_method () |
388 | |
398 | |
389 | NV ev_time () |
399 | NV ev_time () |
390 | |
400 | |
391 | int ev_default_loop (int methods = EVMETHOD_AUTO) |
401 | int ev_default_loop (int methods = EVFLAG_AUTO) |
392 | |
402 | |
393 | void ev_loop (int flags = 0) |
403 | void ev_loop (int flags = 0) |
394 | |
404 | |
395 | void ev_unloop (int how = 1) |
405 | void ev_unloop (int how = 1) |
396 | |
406 | |
… | |
… | |
479 | OUTPUT: |
489 | OUTPUT: |
480 | RETVAL |
490 | RETVAL |
481 | |
491 | |
482 | struct ev_child *child (int pid, SV *cb) |
492 | struct ev_child *child (int pid, SV *cb) |
483 | ALIAS: |
493 | ALIAS: |
484 | check_ns = 1 |
494 | child_ns = 1 |
485 | CODE: |
495 | CODE: |
486 | RETVAL = e_new (sizeof (struct ev_child), cb); |
496 | RETVAL = e_new (sizeof (struct ev_child), cb); |
487 | ev_child_set (RETVAL, pid); |
497 | ev_child_set (RETVAL, pid); |
488 | if (!ix) ev_child_start (RETVAL); |
498 | if (!ix) ev_child_start (RETVAL); |
489 | OUTPUT: |
499 | OUTPUT: |
… | |
… | |
796 | CODE: |
806 | CODE: |
797 | RETVAL = ix ? w->rpid : w->rstatus; |
807 | RETVAL = ix ? w->rpid : w->rstatus; |
798 | OUTPUT: |
808 | OUTPUT: |
799 | RETVAL |
809 | RETVAL |
800 | |
810 | |
801 | #ifndef WIN32 |
811 | #ifndef _WIN32 |
802 | |
812 | |
803 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
813 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
804 | |
814 | |
805 | BOOT: |
815 | BOOT: |
806 | { |
816 | { |
… | |
… | |
877 | |
887 | |
878 | int evdns_set_option (char *option, char *val, int flags) |
888 | int evdns_set_option (char *option, char *val, int flags) |
879 | |
889 | |
880 | int evdns_resolv_conf_parse (int flags, const char *filename) |
890 | int evdns_resolv_conf_parse (int flags, const char *filename) |
881 | |
891 | |
882 | #ifdef MS_WINDOWS |
892 | #ifdef _WIN32 |
883 | |
893 | |
884 | int evdns_config_windows_nameservers () |
894 | int evdns_config_windows_nameservers () |
885 | |
895 | |
886 | #endif |
896 | #endif |
887 | |
897 | |