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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines