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

Comparing EV/EV.xs (file contents):
Revision 1.105 by root, Thu Jan 31 20:10:28 2008 UTC vs.
Revision 1.111 by root, Sun May 18 10:45:36 2008 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>*/ 5/*#include <netinet/in.h>*/
6
7/* fix perl api breakage */
8#undef signal
9#undef sigaction
6 10
7#define EV_PROTOTYPES 1 11#define EV_PROTOTYPES 1
8#define EV_USE_NANOSLEEP EV_USE_MONOTONIC 12#define EV_USE_NANOSLEEP EV_USE_MONOTONIC
9#define EV_H <ev.h> 13#define EV_H <ev.h>
10#include "EV/EVAPI.h" 14#include "EV/EVAPI.h"
11
12/* fix perl api breakage */
13#undef signal
14#undef sigaction
15 15
16#define EV_SELECT_IS_WINSOCKET 0 16#define EV_SELECT_IS_WINSOCKET 0
17#ifdef _WIN32 17#ifdef _WIN32
18# define EV_SELECT_USE_FD_SET 0 18# define EV_SELECT_USE_FD_SET 0
19# define NFDBITS PERL_NFDBITS 19# define NFDBITS PERL_NFDBITS
77 *stash_stat, 77 *stash_stat,
78 *stash_idle, 78 *stash_idle,
79 *stash_prepare, 79 *stash_prepare,
80 *stash_check, 80 *stash_check,
81 *stash_embed, 81 *stash_embed,
82 *stash_fork; 82 *stash_fork,
83 *stash_async;
83 84
84#ifndef SIG_SIZE 85#ifndef SIG_SIZE
85/* kudos to Slaven Rezic for the idea */ 86/* kudos to Slaven Rezic for the idea */
86static char sig_size [] = { SIG_NUM }; 87static char sig_size [] = { SIG_NUM };
87# define SIG_SIZE (sizeof (sig_size) + 1) 88# define SIG_SIZE (sizeof (sig_size) + 1)
375 stash_check = gv_stashpv ("EV::Check" , 1); 376 stash_check = gv_stashpv ("EV::Check" , 1);
376 stash_child = gv_stashpv ("EV::Child" , 1); 377 stash_child = gv_stashpv ("EV::Child" , 1);
377 stash_embed = gv_stashpv ("EV::Embed" , 1); 378 stash_embed = gv_stashpv ("EV::Embed" , 1);
378 stash_stat = gv_stashpv ("EV::Stat" , 1); 379 stash_stat = gv_stashpv ("EV::Stat" , 1);
379 stash_fork = gv_stashpv ("EV::Fork" , 1); 380 stash_fork = gv_stashpv ("EV::Fork" , 1);
381 stash_async = gv_stashpv ("EV::Async" , 1);
380 382
381 { 383 {
382 SV *sv = perl_get_sv ("EV::API", TRUE); 384 SV *sv = perl_get_sv ("EV::API", TRUE);
383 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ 385 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */
384 386
388 evapi.sv_fileno = sv_fileno; 390 evapi.sv_fileno = sv_fileno;
389 evapi.sv_signum = sv_signum; 391 evapi.sv_signum = sv_signum;
390 evapi.supported_backends = ev_supported_backends (); 392 evapi.supported_backends = ev_supported_backends ();
391 evapi.recommended_backends = ev_recommended_backends (); 393 evapi.recommended_backends = ev_recommended_backends ();
392 evapi.embeddable_backends = ev_embeddable_backends (); 394 evapi.embeddable_backends = ev_embeddable_backends ();
393 evapi.time = ev_time; 395 evapi.time_ = ev_time;
394 evapi.sleep = ev_sleep; 396 evapi.sleep_ = ev_sleep;
395 evapi.loop_new = ev_loop_new; 397 evapi.loop_new = ev_loop_new;
396 evapi.loop_destroy = ev_loop_destroy; 398 evapi.loop_destroy = ev_loop_destroy;
397 evapi.loop_fork = ev_loop_fork; 399 evapi.loop_fork = ev_loop_fork;
398 evapi.loop_count = ev_loop_count; 400 evapi.loop_count = ev_loop_count;
399 evapi.now = ev_now; 401 evapi.now = ev_now;
645 if (!ix) START (embed, RETVAL); 647 if (!ix) START (embed, RETVAL);
646} 648}
647 OUTPUT: 649 OUTPUT:
648 RETVAL 650 RETVAL
649 651
652ev_async *async (SV *cb)
653 ALIAS:
654 async_ns = 1
655 CODE:
656 RETVAL = e_new (sizeof (ev_async), cb, default_loop_sv);
657 ev_async_set (RETVAL);
658 if (!ix) START (async, RETVAL);
659 OUTPUT:
660 RETVAL
661
650void once (SV *fh, int events, SV *timeout, SV *cb) 662void once (SV *fh, int events, SV *timeout, SV *cb)
651 CODE: 663 CODE:
652 ev_once ( 664 ev_once (
653 evapi.default_loop, 665 evapi.default_loop,
654 sv_fileno (fh), events, 666 sv_fileno (fh), events,
877 INIT: 889 INIT:
878 CHECK_REPEAT (repeat); 890 CHECK_REPEAT (repeat);
879 CODE: 891 CODE:
880 RESET (timer, w, (w, after, repeat)); 892 RESET (timer, w, (w, after, repeat));
881 893
882NV at (ev_timer *w)
883 CODE:
884 RETVAL = w->at;
885 OUTPUT:
886 RETVAL
887
888MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ 894MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_
889 895
890void ev_periodic_start (ev_periodic *w) 896void ev_periodic_start (ev_periodic *w)
891 INIT: 897 INIT:
892 CHECK_REPEAT (w->interval); 898 CHECK_REPEAT (w->interval);
919 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0)); 925 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0));
920} 926}
921 927
922NV at (ev_periodic *w) 928NV at (ev_periodic *w)
923 CODE: 929 CODE:
924 RETVAL = w->at; 930 RETVAL = ev_periodic_at (w);
925 OUTPUT: 931 OUTPUT:
926 RETVAL 932 RETVAL
927 933
928MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ 934MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_
929 935
1135 CODE: 1141 CODE:
1136 RETVAL = newSVsv (w->fh); 1142 RETVAL = newSVsv (w->fh);
1137 OUTPUT: 1143 OUTPUT:
1138 RETVAL 1144 RETVAL
1139 1145
1146void ev_embed_sweep (ev_embed *w)
1147 C_ARGS: e_loop (w), w
1148
1149MODULE = EV PACKAGE = EV::Async PREFIX = ev_async_
1150
1151void ev_async_start (ev_async *w)
1152 CODE:
1153 START (async, w);
1154
1155void ev_async_stop (ev_async *w)
1156 CODE:
1157 STOP (async, w);
1158
1159void DESTROY (ev_async *w)
1160 CODE:
1161 STOP (async, w);
1162 e_destroy (w);
1163
1164void ev_async_send (ev_async *w)
1165 C_ARGS: e_loop (w), w
1166
1167SV *ev_async_async_pending (ev_async *w)
1168 CODE:
1169 RETVAL = boolSV (ev_async_pending (w));
1170 OUTPUT:
1171 RETVAL
1172
1140MODULE = EV PACKAGE = EV::Loop PREFIX = ev_ 1173MODULE = EV PACKAGE = EV::Loop PREFIX = ev_
1141 1174
1142SV *new (SV *klass, unsigned int flags = 0) 1175SV *new (SV *klass, unsigned int flags = 0)
1143 CODE: 1176 CODE:
1144{ 1177{
1327 1360
1328 if (!SvOK (cb)) ev_set_cb (RETVAL, 0); 1361 if (!SvOK (cb)) ev_set_cb (RETVAL, 0);
1329 1362
1330 if (!ix) START (embed, RETVAL); 1363 if (!ix) START (embed, RETVAL);
1331} 1364}
1365 OUTPUT:
1366 RETVAL
1367
1368ev_async *async (struct ev_loop *loop, SV *cb)
1369 ALIAS:
1370 async_ns = 1
1371 CODE:
1372 RETVAL = e_new (sizeof (ev_async), cb, ST (0));
1373 ev_async_set (RETVAL);
1374 if (!ix) START (async, RETVAL);
1332 OUTPUT: 1375 OUTPUT:
1333 RETVAL 1376 RETVAL
1334 1377
1335void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb) 1378void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb)
1336 CODE: 1379 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines