ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV.xs
(Generate patch)

Comparing EV/EV.xs (file contents):
Revision 1.125 by root, Wed Jul 8 02:46:05 2009 UTC vs.
Revision 1.137 by root, Tue Mar 16 20:43:05 2010 UTC

1#include "EXTERN.h" 1#include "EXTERN.h"
2#include "perl.h" 2#include "perl.h"
3#include "XSUB.h" 3#include "XSUB.h"
4 4
5/*#include <netinet/in.h>*/
6
7/* fix perl api breakage */ 5/* fix perl api breakage */
8#undef signal 6#undef signal
9#undef sigaction 7#undef sigaction
10 8
9#include "schmorp.h"
10
11/* old API compatibility */
12static int
13sv_fileno (SV *fh)
14{
15 return s_fileno (fh, 0);
16}
17
18#define EV_STANDALONE 1
11#define EV_PROTOTYPES 1 19#define EV_PROTOTYPES 1
12#define EV_USE_NANOSLEEP EV_USE_MONOTONIC 20#define EV_USE_NANOSLEEP EV_USE_MONOTONIC
13#define EV_H <ev.h> 21#define EV_H <ev.h>
22#define EV_CONFIG_H error
14#include "EV/EVAPI.h" 23#include "EV/EVAPI.h"
15 24
16#define EV_SELECT_IS_WINSOCKET 0 25#define EV_SELECT_IS_WINSOCKET 0
17#ifdef _WIN32 26#ifdef _WIN32
18# define EV_SELECT_USE_FD_SET 0 27# define EV_SELECT_USE_FD_SET 0
24 33
25#ifndef _WIN32 34#ifndef _WIN32
26# include <pthread.h> 35# include <pthread.h>
27#endif 36#endif
28 37
29/* 5.10.0 */
30#ifndef SvREFCNT_inc_NN
31# define SvREFCNT_inc_NN(sv) SvREFCNT_inc (sv)
32#endif
33
34/* 5.6.x */
35#ifndef SvRV_set
36# define SvRV_set(a,b) SvRV ((a)) = (b)
37#endif
38
39#define e_loop(w) INT2PTR (struct ev_loop *, SvIVX ((w)->loop)) 38#define e_loop(w) INT2PTR (struct ev_loop *, SvIVX ((w)->loop))
40 39
41#define WFLAG_KEEPALIVE 1 40#define WFLAG_KEEPALIVE 1
42#define WFLAG_UNREFED 2 /* has been unref'ed */ 41#define WFLAG_UNREFED 2 /* has been unref'ed */
43 42
67 REF (w); \ 66 REF (w); \
68 ev_ ## type ## _stop (e_loop (w), w); \ 67 ev_ ## type ## _stop (e_loop (w), w); \
69 } while (0) 68 } while (0)
70 69
71#define RESET(type,w,seta) \ 70#define RESET(type,w,seta) \
72 do { \ 71 do { \
73 int active = ev_is_active (w); \ 72 int active = ev_is_active (w); \
74 if (active) STOP (type, w); \ 73 if (active) STOP (type, w); \
75 ev_ ## type ## _set seta; \ 74 ev_ ## type ## _set seta; \
76 if (active) START (type, w); \ 75 if (active) START (type, w); \
77 } while (0) 76 } while (0)
78 77
79typedef int Signal; 78typedef int Signal;
79
80/* horrible... */
81#define CHECK_SIGNAL_CAN_START(w) \
82 do { \
83 /* dive into the internals of libev to avoid aborting in libev */ \
84 if (signals [(w)->signum - 1].loop \
85 && signals [(w)->signum - 1].loop != e_loop (w)) \
86 croak ("unable to start signal watcher, signal %d already registered in another loop", w->signum); \
87 } while (0)
88
89#define START_SIGNAL(w) \
90 do { \
91 CHECK_SIGNAL_CAN_START (w); \
92 START (signal, w); \
93 } while (0) \
94
95#define RESET_SIGNAL(w,seta) \
96 do { \
97 int active = ev_is_active (w); \
98 if (active) STOP (signal, w); \
99 ev_ ## signal ## _set seta; \
100 if (active) START_SIGNAL (w); \
101 } while (0)
80 102
81static SV *default_loop_sv; 103static SV *default_loop_sv;
82 104
83static struct EVAPI evapi; 105static struct EVAPI evapi;
84 106
96 *stash_check, 118 *stash_check,
97 *stash_embed, 119 *stash_embed,
98 *stash_fork, 120 *stash_fork,
99 *stash_async; 121 *stash_async;
100 122
101#ifndef SIG_SIZE
102/* kudos to Slaven Rezic for the idea */
103static char sig_size [] = { SIG_NUM };
104# define SIG_SIZE (sizeof (sig_size) + 1)
105#endif
106
107static Signal
108sv_signum (SV *sig)
109{
110 Signal signum;
111
112 SvGETMAGIC (sig);
113
114 for (signum = 1; signum < SIG_SIZE; ++signum)
115 if (strEQ (SvPV_nolen (sig), PL_sig_name [signum]))
116 return signum;
117
118 signum = SvIV (sig);
119
120 if (signum > 0 && signum < SIG_SIZE)
121 return signum;
122
123 return -1;
124}
125
126///////////////////////////////////////////////////////////////////////////// 123/////////////////////////////////////////////////////////////////////////////
127// Event 124// Event
128 125
129static void e_cb (EV_P_ ev_watcher *w, int revents); 126static void e_cb (EV_P_ ev_watcher *w, int revents);
130 127
131static int
132sv_fileno (SV *fh)
133{
134 SvGETMAGIC (fh);
135
136 if (SvROK (fh))
137 fh = SvRV (fh);
138
139 if (SvTYPE (fh) == SVt_PVGV)
140 return PerlIO_fileno (IoIFP (sv_2io (fh)));
141
142 if (SvOK (fh) && (SvIV (fh) >= 0) && (SvIV (fh) < 0x7fffffffL))
143 return SvIV (fh);
144
145 return -1;
146}
147
148static SV *
149e_get_cv (SV *cb_sv)
150{
151 HV *st;
152 GV *gvp;
153 CV *cv = sv_2cv (cb_sv, &st, &gvp, 0);
154
155 if (!cv)
156 croak ("EV watcher callback must be a CODE reference");
157
158 return (SV *)cv;
159}
160
161static void * 128static void *
162e_new (int size, SV *cb_sv, SV *loop) 129e_new (int size, SV *cb_sv, SV *loop)
163{ 130{
164 SV *cv = cb_sv ? e_get_cv (cb_sv) : 0; 131 SV *cv = cb_sv ? s_get_cv_croak (cb_sv) : 0;
165 ev_watcher *w; 132 ev_watcher *w;
166 SV *self = NEWSV (0, size); 133 SV *self = NEWSV (0, size);
167 SvPOK_only (self); 134 SvPOK_only (self);
168 SvCUR_set (self, size); 135 SvCUR_set (self, size);
169 136
393 const_iv (EV_, UNDEF) 360 const_iv (EV_, UNDEF)
394 const_iv (EV_, NONE) 361 const_iv (EV_, NONE)
395 const_iv (EV_, READ) 362 const_iv (EV_, READ)
396 const_iv (EV_, WRITE) 363 const_iv (EV_, WRITE)
397 const_iv (EV_, IO) 364 const_iv (EV_, IO)
398 const_iv (EV_, TIMEOUT) 365 const_iv (EV_, TIMEOUT) /* deprecated */
399 const_iv (EV_, TIMER) 366 const_iv (EV_, TIMER)
400 const_iv (EV_, PERIODIC) 367 const_iv (EV_, PERIODIC)
401 const_iv (EV_, SIGNAL) 368 const_iv (EV_, SIGNAL)
402 const_iv (EV_, CHILD) 369 const_iv (EV_, CHILD)
403 const_iv (EV_, STAT) 370 const_iv (EV_, STAT)
421 const_iv (EV, BACKEND_POLL) 388 const_iv (EV, BACKEND_POLL)
422 const_iv (EV, BACKEND_EPOLL) 389 const_iv (EV, BACKEND_EPOLL)
423 const_iv (EV, BACKEND_KQUEUE) 390 const_iv (EV, BACKEND_KQUEUE)
424 const_iv (EV, BACKEND_DEVPOLL) 391 const_iv (EV, BACKEND_DEVPOLL)
425 const_iv (EV, BACKEND_PORT) 392 const_iv (EV, BACKEND_PORT)
393 const_iv (EV, BACKEND_ALL)
426 const_iv (EV, FLAG_AUTO) 394 const_iv (EV, FLAG_AUTO)
395 const_iv (EV, FLAG_FORKCHECK)
396 const_iv (EV, FLAG_SIGNALFD)
427 const_iv (EV, FLAG_NOENV) 397 const_iv (EV, FLAG_NOENV)
398 const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */
428 const_iv (EV, FLAG_FORKCHECK) 399 const_iv (EV, FLAG_NOINOTIFY)
429 400
430 const_iv (EV_, VERSION_MAJOR) 401 const_iv (EV_, VERSION_MAJOR)
431 const_iv (EV_, VERSION_MINOR) 402 const_iv (EV_, VERSION_MINOR)
432 }; 403 };
433 404
455 426
456 /* the poor man's shared library emulator */ 427 /* the poor man's shared library emulator */
457 evapi.ver = EV_API_VERSION; 428 evapi.ver = EV_API_VERSION;
458 evapi.rev = EV_API_REVISION; 429 evapi.rev = EV_API_REVISION;
459 evapi.sv_fileno = sv_fileno; 430 evapi.sv_fileno = sv_fileno;
460 evapi.sv_signum = sv_signum; 431 evapi.sv_signum = s_signum;
461 evapi.supported_backends = ev_supported_backends (); 432 evapi.supported_backends = ev_supported_backends ();
462 evapi.recommended_backends = ev_recommended_backends (); 433 evapi.recommended_backends = ev_recommended_backends ();
463 evapi.embeddable_backends = ev_embeddable_backends (); 434 evapi.embeddable_backends = ev_embeddable_backends ();
464 evapi.time_ = ev_time; 435 evapi.time_ = ev_time;
465 evapi.sleep_ = ev_sleep; 436 evapi.sleep_ = ev_sleep;
466 evapi.loop_new = ev_loop_new; 437 evapi.loop_new = ev_loop_new;
467 evapi.loop_destroy = ev_loop_destroy; 438 evapi.loop_destroy = ev_loop_destroy;
468 evapi.loop_fork = ev_loop_fork; 439 evapi.loop_fork = ev_loop_fork;
469 evapi.loop_count = ev_loop_count; 440 evapi.iteration = ev_iteration;
470 evapi.loop_depth = ev_loop_depth; 441 evapi.depth = ev_depth;
442 evapi.set_userdata = ev_set_userdata;
443 evapi.userdata = ev_userdata;
471 evapi.now = ev_now; 444 evapi.now = ev_now;
472 evapi.now_update = ev_now_update; 445 evapi.now_update = ev_now_update;
473 evapi.suspend = ev_suspend; 446 evapi.suspend = ev_suspend;
474 evapi.resume = ev_resume; 447 evapi.resume = ev_resume;
475 evapi.backend = ev_backend; 448 evapi.backend = ev_backend;
476 evapi.unloop = ev_unloop; 449 evapi.unloop = ev_unloop;
450 evapi.invoke_pending = ev_invoke_pending;
451 evapi.pending_count = ev_pending_count;
452 evapi.verify = ev_verify;
453 evapi.set_loop_release_cb = ev_set_loop_release_cb;
454 evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb;
477 evapi.ref = ev_ref; 455 evapi.ref = ev_ref;
478 evapi.unref = ev_unref; 456 evapi.unref = ev_unref;
479 evapi.loop = ev_loop; 457 evapi.loop = ev_loop;
480 evapi.once = ev_once; 458 evapi.once = ev_once;
481 evapi.io_start = ev_io_start; 459 evapi.io_start = ev_io_start;
482 evapi.io_stop = ev_io_stop; 460 evapi.io_stop = ev_io_stop;
483 evapi.timer_start = ev_timer_start; 461 evapi.timer_start = ev_timer_start;
484 evapi.timer_stop = ev_timer_stop; 462 evapi.timer_stop = ev_timer_stop;
485 evapi.timer_again = ev_timer_again; 463 evapi.timer_again = ev_timer_again;
464 evapi.timer_remaining = ev_timer_remaining;
486 evapi.periodic_start = ev_periodic_start; 465 evapi.periodic_start = ev_periodic_start;
487 evapi.periodic_stop = ev_periodic_stop; 466 evapi.periodic_stop = ev_periodic_stop;
488 evapi.signal_start = ev_signal_start; 467 evapi.signal_start = ev_signal_start;
489 evapi.signal_stop = ev_signal_stop; 468 evapi.signal_stop = ev_signal_stop;
490 evapi.idle_start = ev_idle_start; 469 evapi.idle_start = ev_idle_start;
564 C_ARGS: evapi.default_loop 543 C_ARGS: evapi.default_loop
565 544
566unsigned int ev_backend () 545unsigned int ev_backend ()
567 C_ARGS: evapi.default_loop 546 C_ARGS: evapi.default_loop
568 547
569void ev_loop_verify () 548void ev_verify ()
570 C_ARGS: evapi.default_loop 549 C_ARGS: evapi.default_loop
571 550
572unsigned int ev_loop_count () 551unsigned int ev_iteration ()
573 C_ARGS: evapi.default_loop 552 C_ARGS: evapi.default_loop
574 553
575unsigned int ev_loop_depth () 554unsigned int ev_depth ()
576 C_ARGS: evapi.default_loop 555 C_ARGS: evapi.default_loop
577 556
578void ev_set_io_collect_interval (NV interval) 557void ev_set_io_collect_interval (NV interval)
579 C_ARGS: evapi.default_loop, interval 558 C_ARGS: evapi.default_loop, interval
580 559
591 C_ARGS: evapi.default_loop, fd, revents 570 C_ARGS: evapi.default_loop, fd, revents
592 571
593void ev_feed_signal_event (SV *signal) 572void ev_feed_signal_event (SV *signal)
594 CODE: 573 CODE:
595{ 574{
596 Signal signum = sv_signum (signal); 575 Signal signum = s_signum (signal);
597 CHECK_SIG (signal, signum); 576 CHECK_SIG (signal, signum);
598 577
599 ev_feed_signal_event (evapi.default_loop, signum); 578 ev_feed_signal_event (evapi.default_loop, signum);
600} 579}
601 580
581unsigned int ev_pending_count ()
582 C_ARGS: evapi.default_loop
583
584void ev_invoke_pending ()
585 C_ARGS: evapi.default_loop
586
602ev_io *io (SV *fh, int events, SV *cb) 587ev_io *io (SV *fh, int events, SV *cb)
603 ALIAS: 588 ALIAS:
604 io_ns = 1 589 io_ns = 1
590 _ae_io = 2
605 CODE: 591 CODE:
606{ 592{
607 int fd = sv_fileno (fh); 593 int fd = s_fileno (fh, events & EV_WRITE);
608 CHECK_FD (fh, fd); 594 CHECK_FD (fh, fd);
595
596 if (ix == 2)
597 {
598 ix = 0;
599 events = events ? EV_WRITE : EV_READ;
600 }
609 601
610 RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv); 602 RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv);
611 RETVAL->fh = newSVsv (fh); 603 RETVAL->fh = newSVsv (fh);
612 ev_io_set (RETVAL, fd, events); 604 ev_io_set (RETVAL, fd, events);
613 if (!ix) START (io, RETVAL); 605 if (!ix) START (io, RETVAL);
647ev_signal *signal (SV *signal, SV *cb) 639ev_signal *signal (SV *signal, SV *cb)
648 ALIAS: 640 ALIAS:
649 signal_ns = 1 641 signal_ns = 1
650 CODE: 642 CODE:
651{ 643{
652 Signal signum = sv_signum (signal); 644 Signal signum = s_signum (signal);
653 CHECK_SIG (signal, signum); 645 CHECK_SIG (signal, signum);
654 646
655 RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv); 647 RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv);
656 ev_signal_set (RETVAL, signum); 648 ev_signal_set (RETVAL, signum);
657 if (!ix) START (signal, RETVAL); 649 if (!ix) START_SIGNAL (RETVAL);
658} 650}
659 OUTPUT: 651 OUTPUT:
660 RETVAL 652 RETVAL
661 653
662ev_idle *idle (SV *cb) 654ev_idle *idle (SV *cb)
748 740
749void once (SV *fh, int events, SV *timeout, SV *cb) 741void once (SV *fh, int events, SV *timeout, SV *cb)
750 CODE: 742 CODE:
751 ev_once ( 743 ev_once (
752 evapi.default_loop, 744 evapi.default_loop,
753 sv_fileno (fh), events, 745 s_fileno (fh, events & EV_WRITE), events,
754 SvOK (timeout) ? SvNV (timeout) : -1., 746 SvOK (timeout) ? SvNV (timeout) : -1.,
755 e_once_cb, 747 e_once_cb,
756 newSVsv (cb) 748 newSVsv (cb)
757 ); 749 );
758 750
792SV *cb (ev_watcher *w, SV *new_cb = 0) 784SV *cb (ev_watcher *w, SV *new_cb = 0)
793 CODE: 785 CODE:
794{ 786{
795 if (items > 1) 787 if (items > 1)
796 { 788 {
797 new_cb = e_get_cv (new_cb); 789 new_cb = s_get_cv_croak (new_cb);
798 RETVAL = newRV_noinc (w->cb_sv); 790 RETVAL = newRV_noinc (w->cb_sv);
799 w->cb_sv = SvREFCNT_inc (new_cb); 791 w->cb_sv = SvREFCNT_inc (new_cb);
800 } 792 }
801 else 793 else
802 RETVAL = newRV_inc (w->cb_sv); 794 RETVAL = newRV_inc (w->cb_sv);
872 e_destroy (w); 864 e_destroy (w);
873 865
874void set (ev_io *w, SV *fh, int events) 866void set (ev_io *w, SV *fh, int events)
875 CODE: 867 CODE:
876{ 868{
877 int fd = sv_fileno (fh); 869 int fd = s_fileno (fh, events & EV_WRITE);
878 CHECK_FD (fh, fd); 870 CHECK_FD (fh, fd);
879 871
880 sv_setsv (w->fh, fh); 872 sv_setsv (w->fh, fh);
881 RESET (io, w, (w, fd, events)); 873 RESET (io, w, (w, fd, events));
882} 874}
884SV *fh (ev_io *w, SV *new_fh = 0) 876SV *fh (ev_io *w, SV *new_fh = 0)
885 CODE: 877 CODE:
886{ 878{
887 if (items > 1) 879 if (items > 1)
888 { 880 {
889 int fd = sv_fileno (new_fh); 881 int fd = s_fileno (new_fh, w->events & EV_WRITE);
890 CHECK_FD (new_fh, fd); 882 CHECK_FD (new_fh, fd);
891 883
892 RETVAL = w->fh; 884 RETVAL = w->fh;
893 w->fh = newSVsv (new_fh); 885 w->fh = newSVsv (new_fh);
894 886
913 905
914MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ 906MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_
915 907
916void ev_signal_start (ev_signal *w) 908void ev_signal_start (ev_signal *w)
917 CODE: 909 CODE:
918 START (signal, w); 910 START_SIGNAL (w);
919 911
920void ev_signal_stop (ev_signal *w) 912void ev_signal_stop (ev_signal *w)
921 CODE: 913 CODE:
922 STOP (signal, w); 914 STOP (signal, w);
923 915
927 e_destroy (w); 919 e_destroy (w);
928 920
929void set (ev_signal *w, SV *signal) 921void set (ev_signal *w, SV *signal)
930 CODE: 922 CODE:
931{ 923{
932 Signal signum = sv_signum (signal); 924 Signal signum = s_signum (signal);
933 CHECK_SIG (signal, signum); 925 CHECK_SIG (signal, signum);
934 926
935 RESET (signal, w, (w, signum)); 927 RESET_SIGNAL (w, (w, signum));
936} 928}
937 929
938int signal (ev_signal *w, SV *new_signal = 0) 930int signal (ev_signal *w, SV *new_signal = 0)
939 CODE: 931 CODE:
940{ 932{
941 RETVAL = w->signum; 933 RETVAL = w->signum;
942 934
943 if (items > 1) 935 if (items > 1)
944 { 936 {
945 Signal signum = sv_signum (new_signal); 937 Signal signum = s_signum (new_signal);
946 CHECK_SIG (new_signal, signum); 938 CHECK_SIG (new_signal, signum);
947 939
948 RESET (signal, w, (w, signum)); 940 RESET_SIGNAL (w, (w, signum));
949 } 941 }
950} 942}
951 OUTPUT: 943 OUTPUT:
952 RETVAL 944 RETVAL
953 945
967 INIT: 959 INIT:
968 CHECK_REPEAT (w->repeat); 960 CHECK_REPEAT (w->repeat);
969 CODE: 961 CODE:
970 ev_timer_again (e_loop (w), w); 962 ev_timer_again (e_loop (w), w);
971 UNREF (w); 963 UNREF (w);
964
965NV ev_timer_remaining (ev_timer *w)
966 C_ARGS: e_loop (w), w
972 967
973void DESTROY (ev_timer *w) 968void DESTROY (ev_timer *w)
974 CODE: 969 CODE:
975 STOP (timer, w); 970 STOP (timer, w);
976 e_destroy (w); 971 e_destroy (w);
1279 if (loop != evapi.default_loop) /* global destruction sucks */ 1274 if (loop != evapi.default_loop) /* global destruction sucks */
1280 ev_loop_destroy (loop); 1275 ev_loop_destroy (loop);
1281 1276
1282void ev_loop_fork (struct ev_loop *loop) 1277void ev_loop_fork (struct ev_loop *loop)
1283 1278
1284void ev_loop_verify (struct ev_loop *loop) 1279void ev_verify (struct ev_loop *loop)
1285 1280
1286NV ev_now (struct ev_loop *loop) 1281NV ev_now (struct ev_loop *loop)
1287 1282
1288void ev_now_update (struct ev_loop *loop) 1283void ev_now_update (struct ev_loop *loop)
1289 1284
1295 1290
1296void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval) 1291void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1297 1292
1298unsigned int ev_backend (struct ev_loop *loop) 1293unsigned int ev_backend (struct ev_loop *loop)
1299 1294
1300unsigned int ev_loop_count (struct ev_loop *loop) 1295unsigned int ev_iteration (struct ev_loop *loop)
1301 1296
1302unsigned int ev_loop_depth (struct ev_loop *loop) 1297unsigned int ev_depth (struct ev_loop *loop)
1303 1298
1304void ev_loop (struct ev_loop *loop, int flags = 0) 1299void ev_loop (struct ev_loop *loop, int flags = 0)
1305 1300
1306void ev_unloop (struct ev_loop *loop, int how = 1) 1301void ev_unloop (struct ev_loop *loop, int how = 1)
1307 1302
1308void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE) 1303void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE)
1309 1304
1305unsigned int ev_pending_count (struct ev_loop *loop)
1306
1307void ev_invoke_pending (struct ev_loop *loop)
1308
1310#if 0 1309#if 0
1311 1310
1312void ev_feed_signal_event (struct ev_loop *loop, SV *signal) 1311void ev_feed_signal_event (struct ev_loop *loop, SV *signal)
1313 CODE: 1312 CODE:
1314{ 1313{
1315 Signal signum = sv_signum (signal); 1314 Signal signum = s_signum (signal);
1316 CHECK_SIG (signal, signum); 1315 CHECK_SIG (signal, signum);
1317 1316
1318 ev_feed_signal_event (loop, signum); 1317 ev_feed_signal_event (loop, signum);
1319} 1318}
1320 1319
1323ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb) 1322ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb)
1324 ALIAS: 1323 ALIAS:
1325 io_ns = 1 1324 io_ns = 1
1326 CODE: 1325 CODE:
1327{ 1326{
1328 int fd = sv_fileno (fh); 1327 int fd = s_fileno (fh, events & EV_WRITE);
1329 CHECK_FD (fh, fd); 1328 CHECK_FD (fh, fd);
1330 1329
1331 RETVAL = e_new (sizeof (ev_io), cb, ST (0)); 1330 RETVAL = e_new (sizeof (ev_io), cb, ST (0));
1332 RETVAL->fh = newSVsv (fh); 1331 RETVAL->fh = newSVsv (fh);
1333 ev_io_set (RETVAL, fd, events); 1332 ev_io_set (RETVAL, fd, events);
1363 if (!ix) START (periodic, w); 1362 if (!ix) START (periodic, w);
1364} 1363}
1365 OUTPUT: 1364 OUTPUT:
1366 RETVAL 1365 RETVAL
1367 1366
1368#if 0
1369
1370ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb) 1367ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb)
1371 ALIAS: 1368 ALIAS:
1372 signal_ns = 1 1369 signal_ns = 1
1373 CODE: 1370 CODE:
1374{ 1371{
1375 Signal signum = sv_signum (signal); 1372 Signal signum = s_signum (signal);
1376 CHECK_SIG (signal, signum); 1373 CHECK_SIG (signal, signum);
1377 1374
1378 RETVAL = e_new (sizeof (ev_signal), cb, ST (0)); 1375 RETVAL = e_new (sizeof (ev_signal), cb, ST (0));
1379 ev_signal_set (RETVAL, signum); 1376 ev_signal_set (RETVAL, signum);
1380 if (!ix) START (signal, RETVAL); 1377 if (!ix) START_SIGNAL (RETVAL);
1381} 1378}
1382 OUTPUT: 1379 OUTPUT:
1383 RETVAL 1380 RETVAL
1384
1385#endif
1386 1381
1387ev_idle *idle (struct ev_loop *loop, SV *cb) 1382ev_idle *idle (struct ev_loop *loop, SV *cb)
1388 ALIAS: 1383 ALIAS:
1389 idle_ns = 1 1384 idle_ns = 1
1390 CODE: 1385 CODE:
1473 1468
1474void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb) 1469void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb)
1475 CODE: 1470 CODE:
1476 ev_once ( 1471 ev_once (
1477 loop, 1472 loop,
1478 sv_fileno (fh), events, 1473 s_fileno (fh, events & EV_WRITE), events,
1479 SvOK (timeout) ? SvNV (timeout) : -1., 1474 SvOK (timeout) ? SvNV (timeout) : -1.,
1480 e_once_cb, 1475 e_once_cb,
1481 newSVsv (cb) 1476 newSVsv (cb)
1482 ); 1477 );
1483 1478

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines