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

Comparing EV/EV.xs (file contents):
Revision 1.41 by root, Fri Nov 2 20:21:33 2007 UTC vs.
Revision 1.55 by root, Tue Nov 6 12:36:25 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"
21
22#ifndef WIN32
23# include <pthread.h>
24#endif
14 25
15typedef int Signal; 26typedef int Signal;
16 27
17static struct EVAPI evapi; 28static struct EVAPI evapi;
18 29
25 *stash_idle, 36 *stash_idle,
26 *stash_prepare, 37 *stash_prepare,
27 *stash_check, 38 *stash_check,
28 *stash_child; 39 *stash_child;
29 40
41#ifndef SIG_SIZE
42/* kudos to Slaven Rezic for the idea */
43static char sig_size [] = { SIG_NUM };
44# define SIG_SIZE (sizeof (sig_size) + 1)
45#endif
46
30static int 47static int
31sv_signum (SV *sig) 48sv_signum (SV *sig)
32{ 49{
33 int signum; 50 int signum;
34 51
131 148
132 PUSHMARK (SP); 149 PUSHMARK (SP);
133 EXTEND (SP, 2); 150 EXTEND (SP, 2);
134 PUSHs (sv_self); 151 PUSHs (sv_self);
135 PUSHs (sv_events); 152 PUSHs (sv_events);
136
137 if (revents & EV_CHILD)
138 XPUSHs (sv_status = newSViv (((struct ev_child *)w)->status));
139 153
140 PUTBACK; 154 PUTBACK;
141 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); 155 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL);
142 SP = PL_stack_base + mark; PUTBACK; 156 SP = PL_stack_base + mark; PUTBACK;
143 157
251 265
252 const_iv (EV, METHOD_AUTO) 266 const_iv (EV, METHOD_AUTO)
253 const_iv (EV, METHOD_SELECT) 267 const_iv (EV, METHOD_SELECT)
254 const_iv (EV, METHOD_POLL) 268 const_iv (EV, METHOD_POLL)
255 const_iv (EV, METHOD_EPOLL) 269 const_iv (EV, METHOD_EPOLL)
270 const_iv (EV, METHOD_KQUEUE)
271 const_iv (EV, METHOD_DEVPOLL)
272 const_iv (EV, METHOD_PORT)
256 const_iv (EV, METHOD_ANY) 273 const_iv (EV, METHOD_ANY)
257 }; 274 };
258 275
259 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 276 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
260 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 277 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
276 /* the poor man's shared library emulator */ 293 /* the poor man's shared library emulator */
277 evapi.ver = EV_API_VERSION; 294 evapi.ver = EV_API_VERSION;
278 evapi.rev = EV_API_REVISION; 295 evapi.rev = EV_API_REVISION;
279 evapi.sv_fileno = sv_fileno; 296 evapi.sv_fileno = sv_fileno;
280 evapi.sv_signum = sv_signum; 297 evapi.sv_signum = sv_signum;
281 evapi.now = &ev_now; 298 evapi.now = ev_now;
282 evapi.method = &ev_method; 299 evapi.method = ev_method;
283 evapi.loop_done = &ev_loop_done; 300 evapi.unloop = ev_unloop;
284 evapi.time = ev_time; 301 evapi.time = ev_time;
285 evapi.loop = ev_loop; 302 evapi.loop = ev_loop;
286 evapi.once = ev_once; 303 evapi.once = ev_once;
287 evapi.io_start = ev_io_start; 304 evapi.io_start = ev_io_start;
288 evapi.io_stop = ev_io_stop; 305 evapi.io_stop = ev_io_stop;
304 321
305 sv_setiv (sv, (IV)&evapi); 322 sv_setiv (sv, (IV)&evapi);
306 SvREADONLY_on (sv); 323 SvREADONLY_on (sv);
307 } 324 }
308 325
309 pthread_atfork (ev_fork_prepare, ev_fork_parent, ev_fork_child); 326 #ifndef WIN32
327 pthread_atfork (0, 0, ev_default_fork);
328 #endif
310} 329}
311 330
312NV ev_now () 331NV ev_now ()
313 CODE:
314 RETVAL = ev_now;
315 OUTPUT:
316 RETVAL
317 332
318int ev_method () 333int ev_method ()
319 CODE:
320 RETVAL = ev_method;
321 OUTPUT:
322 RETVAL
323 334
324NV ev_time () 335NV ev_time ()
325 336
326void ev_init (int methods = EVMETHOD_AUTO) 337int ev_default_loop (int methods = EVMETHOD_AUTO)
327 338
328void ev_loop (int flags = 0) 339void ev_loop (int flags = 0)
329 340
330void ev_loop_done (int value = 1) 341void ev_unloop (int how = 1)
331 CODE:
332 ev_loop_done = value;
333 342
334struct ev_io *io (SV *fh, int events, SV *cb) 343struct ev_io *io (SV *fh, int events, SV *cb)
335 ALIAS: 344 ALIAS:
336 io_ns = 1 345 io_ns = 1
337 CODE: 346 CODE:
413 422
414struct ev_child *child (int pid, SV *cb) 423struct ev_child *child (int pid, SV *cb)
415 ALIAS: 424 ALIAS:
416 check_ns = 1 425 check_ns = 1
417 CODE: 426 CODE:
418 RETVAL = e_new (sizeof (struct ev_check), cb); 427 RETVAL = e_new (sizeof (struct ev_child), cb);
419 ev_child_set (RETVAL, pid); 428 ev_child_set (RETVAL, pid);
420 if (!ix) ev_child_start (RETVAL); 429 if (!ix) ev_child_start (RETVAL);
421 OUTPUT: 430 OUTPUT:
422 RETVAL 431 RETVAL
423 432
580 } 589 }
581} 590}
582 OUTPUT: 591 OUTPUT:
583 RETVAL 592 RETVAL
584 593
585MODULE = EV PACKAGE = EV::Time
586
587MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ 594MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_
588 595
589void ev_timer_start (struct ev_timer *w) 596void ev_timer_start (struct ev_timer *w)
590 INIT: 597 INIT:
591 CHECK_REPEAT (w->repeat); 598 CHECK_REPEAT (w->repeat);
710} 717}
711 OUTPUT: 718 OUTPUT:
712 RETVAL 719 RETVAL
713 720
714 721
715int status (struct ev_child *w) 722int rstatus (struct ev_child *w)
723 ALIAS:
724 rpid = 1
716 CODE: 725 CODE:
717 RETVAL = w->status; 726 RETVAL = ix ? w->rpid : w->rstatus;
718 OUTPUT: 727 OUTPUT:
719 RETVAL 728 RETVAL
720 729
721MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ 730MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_
722 731

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines