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

Comparing EV/EV.xs (file contents):
Revision 1.42 by root, Fri Nov 2 22:03:00 2007 UTC vs.
Revision 1.50 by root, Sun Nov 4 16:52:52 2007 UTC

8#include "EV/EVAPI.h" 8#include "EV/EVAPI.h"
9 9
10#include "libev/ev.c" 10#include "libev/ev.c"
11#include "libev/event.h" 11#include "libev/event.h"
12#include "libev/event.c" 12#include "libev/event.c"
13#define DNS_USE_GETTIMEOFDAY_FOR_ID 1
14#define HAVE_STRUCT_IN6_ADDR 1
15#undef HAVE_STRTOK_R
16#undef strtok_r
17#define strtok_r fake_strtok_r
18#include "libev/evdns.h"
13#include "libev/evdns.c" 19#include "libev/evdns.c"
14 20
15typedef int Signal; 21typedef int Signal;
16 22
17static struct EVAPI evapi; 23static struct EVAPI evapi;
25 *stash_idle, 31 *stash_idle,
26 *stash_prepare, 32 *stash_prepare,
27 *stash_check, 33 *stash_check,
28 *stash_child; 34 *stash_child;
29 35
36#ifndef SIG_SIZE
37/* kudos to Slaven Rezic for the idea */
38static char sig_size [] = { SIG_NUM };
39# define SIG_SIZE (sizeof (sig_size) + 1)
40#endif
41
30static int 42static int
31sv_signum (SV *sig) 43sv_signum (SV *sig)
32{ 44{
33 int signum; 45 int signum;
34 46
131 143
132 PUSHMARK (SP); 144 PUSHMARK (SP);
133 EXTEND (SP, 2); 145 EXTEND (SP, 2);
134 PUSHs (sv_self); 146 PUSHs (sv_self);
135 PUSHs (sv_events); 147 PUSHs (sv_events);
136
137 if (revents & EV_CHILD)
138 XPUSHs (sv_status = newSViv (((struct ev_child *)w)->status));
139 148
140 PUTBACK; 149 PUTBACK;
141 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); 150 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL);
142 SP = PL_stack_base + mark; PUTBACK; 151 SP = PL_stack_base + mark; PUTBACK;
143 152
279 /* the poor man's shared library emulator */ 288 /* the poor man's shared library emulator */
280 evapi.ver = EV_API_VERSION; 289 evapi.ver = EV_API_VERSION;
281 evapi.rev = EV_API_REVISION; 290 evapi.rev = EV_API_REVISION;
282 evapi.sv_fileno = sv_fileno; 291 evapi.sv_fileno = sv_fileno;
283 evapi.sv_signum = sv_signum; 292 evapi.sv_signum = sv_signum;
284 evapi.now = &ev_now; 293 evapi.now = ev_now;
285 evapi.method = &ev_method; 294 evapi.method = ev_method;
286 evapi.loop_done = &ev_loop_done; 295 evapi.unloop = ev_unloop;
287 evapi.time = ev_time; 296 evapi.time = ev_time;
288 evapi.loop = ev_loop; 297 evapi.loop = ev_loop;
289 evapi.once = ev_once; 298 evapi.once = ev_once;
290 evapi.io_start = ev_io_start; 299 evapi.io_start = ev_io_start;
291 evapi.io_stop = ev_io_stop; 300 evapi.io_stop = ev_io_stop;
307 316
308 sv_setiv (sv, (IV)&evapi); 317 sv_setiv (sv, (IV)&evapi);
309 SvREADONLY_on (sv); 318 SvREADONLY_on (sv);
310 } 319 }
311 320
312 pthread_atfork (ev_fork_prepare, ev_fork_parent, ev_fork_child); 321 pthread_atfork (0, 0, ev_default_fork);
313} 322}
314 323
315NV ev_now () 324NV ev_now ()
316 CODE:
317 RETVAL = ev_now;
318 OUTPUT:
319 RETVAL
320 325
321int ev_method () 326int ev_method ()
322 CODE:
323 RETVAL = ev_method;
324 OUTPUT:
325 RETVAL
326 327
327NV ev_time () 328NV ev_time ()
328 329
329void ev_init (int methods = EVMETHOD_AUTO) 330int ev_default_loop (int methods = EVMETHOD_AUTO)
330 331
331void ev_loop (int flags = 0) 332void ev_loop (int flags = 0)
332 333
333void ev_loop_done (int value = 1) 334void ev_unloop (int how = 1)
334 CODE:
335 ev_loop_done = value;
336 335
337struct ev_io *io (SV *fh, int events, SV *cb) 336struct ev_io *io (SV *fh, int events, SV *cb)
338 ALIAS: 337 ALIAS:
339 io_ns = 1 338 io_ns = 1
340 CODE: 339 CODE:
416 415
417struct ev_child *child (int pid, SV *cb) 416struct ev_child *child (int pid, SV *cb)
418 ALIAS: 417 ALIAS:
419 check_ns = 1 418 check_ns = 1
420 CODE: 419 CODE:
421 RETVAL = e_new (sizeof (struct ev_check), cb); 420 RETVAL = e_new (sizeof (struct ev_child), cb);
422 ev_child_set (RETVAL, pid); 421 ev_child_set (RETVAL, pid);
423 if (!ix) ev_child_start (RETVAL); 422 if (!ix) ev_child_start (RETVAL);
424 OUTPUT: 423 OUTPUT:
425 RETVAL 424 RETVAL
426 425
713} 712}
714 OUTPUT: 713 OUTPUT:
715 RETVAL 714 RETVAL
716 715
717 716
718int status (struct ev_child *w) 717int rstatus (struct ev_child *w)
718 ALIAS:
719 rpid = 1
719 CODE: 720 CODE:
720 RETVAL = w->status; 721 RETVAL = ix ? w->rpid : w->rstatus;
721 OUTPUT: 722 OUTPUT:
722 RETVAL 723 RETVAL
723 724
724MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ 725MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_
725 726

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines