… | |
… | |
17 | return s_fileno (fh, 0); |
17 | return s_fileno (fh, 0); |
18 | } |
18 | } |
19 | |
19 | |
20 | #ifndef GvCV_set |
20 | #ifndef GvCV_set |
21 | # define GvCV_set(gv,cv) GvCV (gv) = cv |
21 | # define GvCV_set(gv,cv) GvCV (gv) = cv |
|
|
22 | #endif |
|
|
23 | |
|
|
24 | #if EV_ENABLE_ASSERTIONS |
|
|
25 | # undef NDEBUG |
|
|
26 | # include <assert.h> |
22 | #endif |
27 | #endif |
23 | |
28 | |
24 | #define EV_STANDALONE 1 |
29 | #define EV_STANDALONE 1 |
25 | #define EV_PROTOTYPES 1 |
30 | #define EV_PROTOTYPES 1 |
26 | #define EV_USE_NANOSLEEP EV_USE_MONOTONIC |
31 | #define EV_USE_NANOSLEEP EV_USE_MONOTONIC |
27 | #define EV_USE_FLOOR 1 |
32 | #define EV_USE_FLOOR 1 |
28 | #define EV_API_STATIC |
33 | #define EV_API_STATIC |
29 | #define EV_H <ev.h> |
34 | #define EV_H "../libev/ev.h" |
30 | #define EV_CONFIG_H error |
35 | #define EV_CONFIG_H error |
31 | #include "EV/EVAPI.h" |
36 | #include "EV/EVAPI.h" |
32 | |
37 | |
33 | #define EV_SELECT_IS_WINSOCKET 0 |
38 | #define EV_SELECT_IS_WINSOCKET 0 |
34 | #ifdef _WIN32 |
39 | #ifdef _WIN32 |
… | |
… | |
37 | # define fd_mask Perl_fd_mask |
42 | # define fd_mask Perl_fd_mask |
38 | #endif |
43 | #endif |
39 | /* due to bugs in OS X we have to use libev/ explicitly here */ |
44 | /* due to bugs in OS X we have to use libev/ explicitly here */ |
40 | #include "libev/ev.c" |
45 | #include "libev/ev.c" |
41 | |
46 | |
42 | #if !defined _WIN32 && !defined _MINIX && !EV_NO_ATFORK |
47 | #if !defined _WIN32 && !defined __minix && !EV_NO_ATFORK |
43 | # include <pthread.h> |
48 | # include <pthread.h> |
44 | #endif |
49 | #endif |
45 | |
50 | |
46 | #define e_loop(w) INT2PTR (struct ev_loop *, SvIVX (((ev_watcher *)(w))->loop)) |
51 | #define e_loop(w) INT2PTR (struct ev_loop *, SvIVX (((ev_watcher *)(w))->loop)) |
47 | #define e_flags(w) ((ev_watcher *)(w))->e_flags |
52 | #define e_flags(w) ((ev_watcher *)(w))->e_flags |
… | |
… | |
197 | dSP; |
202 | dSP; |
198 | I32 mark = SP - PL_stack_base; |
203 | I32 mark = SP - PL_stack_base; |
199 | SV *sv_self, *sv_events; |
204 | SV *sv_self, *sv_events; |
200 | |
205 | |
201 | /* libev might have stopped the watcher */ |
206 | /* libev might have stopped the watcher */ |
202 | if (expect_false (w->e_flags & WFLAG_UNREFED) |
207 | if (ecb_expect_false (w->e_flags & WFLAG_UNREFED) |
203 | && !ev_is_active (w)) |
208 | && !ev_is_active (w)) |
204 | REF (w); |
209 | REF (w); |
205 | |
210 | |
206 | if (expect_true (sv_self_cache)) |
211 | if (ecb_expect_true (sv_self_cache)) |
207 | { |
212 | { |
208 | sv_self = sv_self_cache; sv_self_cache = 0; |
213 | sv_self = sv_self_cache; sv_self_cache = 0; |
209 | SvRV_set (sv_self, SvREFCNT_inc_NN (w->self)); |
214 | SvRV_set (sv_self, SvREFCNT_inc_NN (w->self)); |
210 | } |
215 | } |
211 | else |
216 | else |
212 | { |
217 | { |
213 | sv_self = newRV_inc (w->self); /* e_self (w) MUST be blessed by now */ |
218 | sv_self = newRV_inc (w->self); /* e_self (w) MUST be blessed by now */ |
214 | SvREADONLY_on (sv_self); |
219 | SvREADONLY_on (sv_self); |
215 | } |
220 | } |
216 | |
221 | |
217 | if (expect_true (sv_events_cache)) |
222 | if (ecb_expect_true (sv_events_cache)) |
218 | { |
223 | { |
219 | sv_events = sv_events_cache; sv_events_cache = 0; |
224 | sv_events = sv_events_cache; sv_events_cache = 0; |
220 | SvIV_set (sv_events, revents); |
225 | SvIV_set (sv_events, revents); |
221 | SvIOK_only (sv_events); |
226 | SvIOK_only (sv_events); |
222 | } |
227 | } |
… | |
… | |
232 | PUSHs (sv_events); |
237 | PUSHs (sv_events); |
233 | |
238 | |
234 | PUTBACK; |
239 | PUTBACK; |
235 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
240 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
236 | |
241 | |
237 | if (expect_false (SvREFCNT (sv_self) != 1 || sv_self_cache)) |
242 | if (ecb_expect_false (SvREFCNT (sv_self) != 1 || sv_self_cache)) |
238 | SvREFCNT_dec (sv_self); |
243 | SvREFCNT_dec (sv_self); |
239 | else |
244 | else |
240 | { |
245 | { |
241 | SvREFCNT_dec (SvRV (sv_self)); |
246 | SvREFCNT_dec (SvRV (sv_self)); |
242 | SvRV_set (sv_self, &PL_sv_undef); |
247 | SvRV_set (sv_self, &PL_sv_undef); |
243 | sv_self_cache = sv_self; |
248 | sv_self_cache = sv_self; |
244 | } |
249 | } |
245 | |
250 | |
246 | if (expect_false (SvREFCNT (sv_events) != 1 || sv_events_cache)) |
251 | if (ecb_expect_false (SvREFCNT (sv_events) != 1 || sv_events_cache)) |
247 | SvREFCNT_dec (sv_events); |
252 | SvREFCNT_dec (sv_events); |
248 | else |
253 | else |
249 | sv_events_cache = sv_events; |
254 | sv_events_cache = sv_events; |
250 | |
255 | |
251 | if (expect_false (SvTRUE (ERRSV))) |
256 | if (ecb_expect_false (SvTRUE (ERRSV))) |
252 | { |
257 | { |
253 | SPAGAIN; |
258 | SPAGAIN; |
254 | PUSHMARK (SP); |
259 | PUSHMARK (SP); |
255 | PUTBACK; |
260 | PUTBACK; |
256 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
261 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
… | |
… | |
534 | |
539 | |
535 | sv_setiv (sv, (IV)&evapi); |
540 | sv_setiv (sv, (IV)&evapi); |
536 | SvREADONLY_on (sv); |
541 | SvREADONLY_on (sv); |
537 | } |
542 | } |
538 | #if !defined _WIN32 && !defined _MINIX && !EV_NO_ATFORK |
543 | #if !defined _WIN32 && !defined _MINIX && !EV_NO_ATFORK |
539 | #if __linux |
544 | /* unfortunately, musl neither implements the linux standard base, |
|
|
545 | /* nor makes itself detectable via macros. yeah, right... */ |
|
|
546 | #if __linux && (__GLIBC__ || __UCLIBC__) |
540 | int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void * __dso_handle); |
547 | int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void * __dso_handle); |
541 | __register_atfork (0, 0, default_fork, 0); |
548 | __register_atfork (0, 0, default_fork, 0); |
542 | #else |
549 | #else |
543 | pthread_atfork (0, 0, default_fork); |
550 | pthread_atfork (0, 0, default_fork); |
544 | #endif |
551 | #endif |
… | |
… | |
988 | CODE: |
995 | CODE: |
989 | { |
996 | { |
990 | RETVAL = w->events; |
997 | RETVAL = w->events; |
991 | |
998 | |
992 | if (items > 1) |
999 | if (items > 1) |
993 | RESET (io, w, (w, w->fd, new_events)); |
1000 | { |
|
|
1001 | int active = ev_is_active (w); |
|
|
1002 | if (active) STOP (io, w); |
|
|
1003 | ev_io_modify (w, new_events); |
|
|
1004 | if (active) START (io, w); |
|
|
1005 | } |
994 | } |
1006 | } |
995 | OUTPUT: |
1007 | OUTPUT: |
996 | RETVAL |
1008 | RETVAL |
997 | |
1009 | |
998 | MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ |
1010 | MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ |
… | |
… | |
1045 | |
1057 | |
1046 | void ev_timer_stop (ev_timer *w) |
1058 | void ev_timer_stop (ev_timer *w) |
1047 | CODE: |
1059 | CODE: |
1048 | STOP (timer, w); |
1060 | STOP (timer, w); |
1049 | |
1061 | |
1050 | void ev_timer_again (ev_timer *w) |
1062 | void ev_timer_again (ev_timer *w, NV repeat = NO_INIT) |
1051 | INIT: |
1063 | CODE: |
|
|
1064 | if (items > 1) |
|
|
1065 | w->repeat = repeat; |
1052 | CHECK_REPEAT (w->repeat); |
1066 | CHECK_REPEAT (w->repeat); |
1053 | CODE: |
|
|
1054 | ev_timer_again (e_loop (w), w); |
1067 | ev_timer_again (e_loop (w), w); |
1055 | UNREF (w); |
1068 | UNREF (w); |
1056 | |
1069 | |
1057 | NV ev_timer_remaining (ev_timer *w) |
1070 | NV ev_timer_remaining (ev_timer *w) |
1058 | C_ARGS: e_loop (w), w |
1071 | C_ARGS: e_loop (w), w |