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.47 by root, Sat Nov 3 21:58:51 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines