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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines