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.54 by root, Tue Nov 6 12:31:20 2007 UTC

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