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.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
251 259
252 const_iv (EV, METHOD_AUTO) 260 const_iv (EV, METHOD_AUTO)
253 const_iv (EV, METHOD_SELECT) 261 const_iv (EV, METHOD_SELECT)
254 const_iv (EV, METHOD_POLL) 262 const_iv (EV, METHOD_POLL)
255 const_iv (EV, METHOD_EPOLL) 263 const_iv (EV, METHOD_EPOLL)
264 const_iv (EV, METHOD_KQUEUE)
265 const_iv (EV, METHOD_DEVPOLL)
266 const_iv (EV, METHOD_PORT)
256 const_iv (EV, METHOD_ANY) 267 const_iv (EV, METHOD_ANY)
257 }; 268 };
258 269
259 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 270 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
260 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 271 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
276 /* the poor man's shared library emulator */ 287 /* the poor man's shared library emulator */
277 evapi.ver = EV_API_VERSION; 288 evapi.ver = EV_API_VERSION;
278 evapi.rev = EV_API_REVISION; 289 evapi.rev = EV_API_REVISION;
279 evapi.sv_fileno = sv_fileno; 290 evapi.sv_fileno = sv_fileno;
280 evapi.sv_signum = sv_signum; 291 evapi.sv_signum = sv_signum;
281 evapi.now = &ev_now; 292 evapi.now = ev_now;
282 evapi.method = &ev_method; 293 evapi.method = ev_method;
283 evapi.loop_done = &ev_loop_done; 294 evapi.unloop = ev_unloop;
284 evapi.time = ev_time; 295 evapi.time = ev_time;
285 evapi.loop = ev_loop; 296 evapi.loop = ev_loop;
286 evapi.once = ev_once; 297 evapi.once = ev_once;
287 evapi.io_start = ev_io_start; 298 evapi.io_start = ev_io_start;
288 evapi.io_stop = ev_io_stop; 299 evapi.io_stop = ev_io_stop;
304 315
305 sv_setiv (sv, (IV)&evapi); 316 sv_setiv (sv, (IV)&evapi);
306 SvREADONLY_on (sv); 317 SvREADONLY_on (sv);
307 } 318 }
308 319
309 pthread_atfork (ev_fork_prepare, ev_fork_parent, ev_fork_child); 320 pthread_atfork (0, 0, ev_default_fork);
310} 321}
311 322
312NV ev_now () 323NV ev_now ()
313 CODE:
314 RETVAL = ev_now;
315 OUTPUT:
316 RETVAL
317 324
318int ev_method () 325int ev_method ()
319 CODE:
320 RETVAL = ev_method;
321 OUTPUT:
322 RETVAL
323 326
324NV ev_time () 327NV ev_time ()
325 328
326void ev_init (int methods = EVMETHOD_AUTO) 329int ev_init (int methods = EVMETHOD_AUTO)
327 330
328void ev_loop (int flags = 0) 331void ev_loop (int flags = 0)
329 332
330void ev_loop_done (int value = 1) 333void ev_unloop (int how = 1)
331 CODE:
332 ev_loop_done = value;
333 334
334struct ev_io *io (SV *fh, int events, SV *cb) 335struct ev_io *io (SV *fh, int events, SV *cb)
335 ALIAS: 336 ALIAS:
336 io_ns = 1 337 io_ns = 1
337 CODE: 338 CODE:
413 414
414struct ev_child *child (int pid, SV *cb) 415struct ev_child *child (int pid, SV *cb)
415 ALIAS: 416 ALIAS:
416 check_ns = 1 417 check_ns = 1
417 CODE: 418 CODE:
418 RETVAL = e_new (sizeof (struct ev_check), cb); 419 RETVAL = e_new (sizeof (struct ev_child), cb);
419 ev_child_set (RETVAL, pid); 420 ev_child_set (RETVAL, pid);
420 if (!ix) ev_child_start (RETVAL); 421 if (!ix) ev_child_start (RETVAL);
421 OUTPUT: 422 OUTPUT:
422 RETVAL 423 RETVAL
423 424
710} 711}
711 OUTPUT: 712 OUTPUT:
712 RETVAL 713 RETVAL
713 714
714 715
715int status (struct ev_child *w) 716int rstatus (struct ev_child *w)
717 ALIAS:
718 rpid = 1
716 CODE: 719 CODE:
717 RETVAL = w->status; 720 RETVAL = ix ? w->rpid : w->rstatus;
718 OUTPUT: 721 OUTPUT:
719 RETVAL 722 RETVAL
720 723
721MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ 724MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_
722 725

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines