… | |
… | |
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 |
… | |
… | |
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 |
… | |
… | |
580 | NV ev_time () |
587 | NV ev_time () |
581 | |
588 | |
582 | void ev_feed_signal (SV *signal) |
589 | void ev_feed_signal (SV *signal) |
583 | CODE: |
590 | CODE: |
584 | { |
591 | { |
585 | Signal signum = s_signum (signal); |
592 | Signal signum = s_signum (signal); |
586 | CHECK_SIG (signal, signum); |
593 | CHECK_SIG (signal, signum); |
587 | |
594 | |
588 | ev_feed_signal (signum); |
595 | ev_feed_signal (signum); |
589 | } |
596 | } |
590 | |
597 | |
… | |
… | |
692 | periodic_ns = 1 |
699 | periodic_ns = 1 |
693 | INIT: |
700 | INIT: |
694 | CHECK_REPEAT (interval); |
701 | CHECK_REPEAT (interval); |
695 | CODE: |
702 | CODE: |
696 | { |
703 | { |
697 | ev_periodic *w; |
704 | ev_periodic *w; |
698 | w = e_new (sizeof (ev_periodic), cb, default_loop_sv); |
705 | w = e_new (sizeof (ev_periodic), cb, default_loop_sv); |
699 | e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
706 | e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
700 | ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0); |
707 | ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0); |
701 | RETVAL = e_bless ((ev_watcher *)w, stash_periodic); |
708 | RETVAL = e_bless ((ev_watcher *)w, stash_periodic); |
702 | if (!ix) START (periodic, w); |
709 | if (!ix) START (periodic, w); |
… | |
… | |
707 | ev_signal *signal (SV *signal, SV *cb) |
714 | ev_signal *signal (SV *signal, SV *cb) |
708 | ALIAS: |
715 | ALIAS: |
709 | signal_ns = 1 |
716 | signal_ns = 1 |
710 | CODE: |
717 | CODE: |
711 | { |
718 | { |
712 | Signal signum = s_signum (signal); |
719 | Signal signum = s_signum (signal); |
713 | CHECK_SIG (signal, signum); |
720 | CHECK_SIG (signal, signum); |
714 | |
721 | |
715 | RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv); |
722 | RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv); |
716 | ev_signal_set (RETVAL, signum); |
723 | ev_signal_set (RETVAL, signum); |
717 | if (!ix) START_SIGNAL (RETVAL); |
724 | if (!ix) START_SIGNAL (RETVAL); |
… | |
… | |
1045 | |
1052 | |
1046 | void ev_timer_stop (ev_timer *w) |
1053 | void ev_timer_stop (ev_timer *w) |
1047 | CODE: |
1054 | CODE: |
1048 | STOP (timer, w); |
1055 | STOP (timer, w); |
1049 | |
1056 | |
1050 | void ev_timer_again (ev_timer *w) |
1057 | void ev_timer_again (ev_timer *w, NV repeat = NO_INIT) |
1051 | INIT: |
1058 | CODE: |
|
|
1059 | if (items > 1) |
|
|
1060 | w->repeat = repeat; |
1052 | CHECK_REPEAT (w->repeat); |
1061 | CHECK_REPEAT (w->repeat); |
1053 | CODE: |
|
|
1054 | ev_timer_again (e_loop (w), w); |
1062 | ev_timer_again (e_loop (w), w); |
1055 | UNREF (w); |
1063 | UNREF (w); |
1056 | |
1064 | |
1057 | NV ev_timer_remaining (ev_timer *w) |
1065 | NV ev_timer_remaining (ev_timer *w) |
1058 | C_ARGS: e_loop (w), w |
1066 | C_ARGS: e_loop (w), w |