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

Comparing EV/EV.xs (file contents):
Revision 1.46 by root, Sat Nov 3 10:37:28 2007 UTC vs.
Revision 1.56 by root, Tue Nov 6 16:09:37 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/* fix perl api breakage */
11#undef signal
12#undef sigaction
13
14/* due to bugs in OS X we have to use libev/ explicitly here */
10#include "libev/ev.c" 15#include "libev/ev.c"
11#include "libev/event.h"
12#include "libev/event.c" 16#include "event.c"
17
18#ifndef WIN32
19#define DNS_USE_GETTIMEOFDAY_FOR_ID 1
20#if !defined (WIN32) && !defined(__CYGWIN__)
21# define HAVE_STRUCT_IN6_ADDR 1
22#endif
23#undef HAVE_STRTOK_R
24#undef strtok_r
25#define strtok_r fake_strtok_r
13#include "libev/evdns.c" 26#include "evdns.c"
27#endif
28
29#ifndef WIN32
30# include <pthread.h>
31#endif
14 32
15typedef int Signal; 33typedef int Signal;
16 34
17static struct EVAPI evapi; 35static struct EVAPI evapi;
18 36
89 w->self = self; 107 w->self = self;
90 108
91 return (void *)w; 109 return (void *)w;
92} 110}
93 111
94static void * 112static void
95e_destroy (void *w_) 113e_destroy (void *w_)
96{ 114{
97 struct ev_watcher *w = w_; 115 struct ev_watcher *w = w_;
98 116
99 SvREFCNT_dec (w->fh ); w->fh = 0; 117 SvREFCNT_dec (w->fh ); w->fh = 0;
162} 180}
163 181
164///////////////////////////////////////////////////////////////////////////// 182/////////////////////////////////////////////////////////////////////////////
165// DNS 183// DNS
166 184
185#ifndef WIN32
167static void 186static void
168dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) 187dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg)
169{ 188{
170 dSP; 189 dSP;
171 SV *cb = (SV *)arg; 190 SV *cb = (SV *)arg;
210 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); 229 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
211 } 230 }
212 231
213 LEAVE; 232 LEAVE;
214} 233}
234#endif
215 235
216#define CHECK_REPEAT(repeat) if (repeat < 0.) \ 236#define CHECK_REPEAT(repeat) if (repeat < 0.) \
217 croak (# repeat " value must be >= 0"); 237 croak (# repeat " value must be >= 0");
218 238
219#define CHECK_FD(fh,fd) if ((fd) < 0) \ 239#define CHECK_FD(fh,fd) if ((fd) < 0) \
226 246
227PROTOTYPES: ENABLE 247PROTOTYPES: ENABLE
228 248
229BOOT: 249BOOT:
230{ 250{
231 int i;
232 HV *stash = gv_stashpv ("EV", 1); 251 HV *stash = gv_stashpv ("EV", 1);
233 252
234 static const struct { 253 static const struct {
235 const char *name; 254 const char *name;
236 IV iv; 255 IV iv;
282 /* the poor man's shared library emulator */ 301 /* the poor man's shared library emulator */
283 evapi.ver = EV_API_VERSION; 302 evapi.ver = EV_API_VERSION;
284 evapi.rev = EV_API_REVISION; 303 evapi.rev = EV_API_REVISION;
285 evapi.sv_fileno = sv_fileno; 304 evapi.sv_fileno = sv_fileno;
286 evapi.sv_signum = sv_signum; 305 evapi.sv_signum = sv_signum;
287 evapi.now = &ev_now; 306 evapi.now = ev_now;
288 evapi.method = &ev_method; 307 evapi.method = ev_method;
289 evapi.loop_done = &ev_loop_done; 308 evapi.unloop = ev_unloop;
290 evapi.time = ev_time; 309 evapi.time = ev_time;
291 evapi.loop = ev_loop; 310 evapi.loop = ev_loop;
292 evapi.once = ev_once; 311 evapi.once = ev_once;
293 evapi.io_start = ev_io_start; 312 evapi.io_start = ev_io_start;
294 evapi.io_stop = ev_io_stop; 313 evapi.io_stop = ev_io_stop;
309 evapi.child_stop = ev_child_stop; 328 evapi.child_stop = ev_child_stop;
310 329
311 sv_setiv (sv, (IV)&evapi); 330 sv_setiv (sv, (IV)&evapi);
312 SvREADONLY_on (sv); 331 SvREADONLY_on (sv);
313 } 332 }
314 333#ifndef WIN32
315 pthread_atfork (ev_fork_prepare, ev_fork_parent, ev_fork_child); 334 pthread_atfork (0, 0, ev_default_fork);
335#endif
316} 336}
317 337
318NV ev_now () 338NV ev_now ()
319 CODE:
320 RETVAL = ev_now;
321 OUTPUT:
322 RETVAL
323 339
324int ev_method () 340int ev_method ()
325 CODE:
326 RETVAL = ev_method;
327 OUTPUT:
328 RETVAL
329 341
330NV ev_time () 342NV ev_time ()
331 343
332int ev_init (int methods = EVMETHOD_AUTO) 344int ev_default_loop (int methods = EVMETHOD_AUTO)
333 345
334void ev_loop (int flags = 0) 346void ev_loop (int flags = 0)
335 347
336void ev_loop_done (int value = 1) 348void ev_unloop (int how = 1)
337 CODE:
338 ev_loop_done = value;
339 349
340struct ev_io *io (SV *fh, int events, SV *cb) 350struct ev_io *io (SV *fh, int events, SV *cb)
341 ALIAS: 351 ALIAS:
342 io_ns = 1 352 io_ns = 1
343 CODE: 353 CODE:
586 } 596 }
587} 597}
588 OUTPUT: 598 OUTPUT:
589 RETVAL 599 RETVAL
590 600
591MODULE = EV PACKAGE = EV::Time
592
593MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ 601MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_
594 602
595void ev_timer_start (struct ev_timer *w) 603void ev_timer_start (struct ev_timer *w)
596 INIT: 604 INIT:
597 CHECK_REPEAT (w->repeat); 605 CHECK_REPEAT (w->repeat);
723 rpid = 1 731 rpid = 1
724 CODE: 732 CODE:
725 RETVAL = ix ? w->rpid : w->rstatus; 733 RETVAL = ix ? w->rpid : w->rstatus;
726 OUTPUT: 734 OUTPUT:
727 RETVAL 735 RETVAL
736
737#ifndef WIN32
728 738
729MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ 739MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_
730 740
731BOOT: 741BOOT:
732{ 742{
857 867
858#void DESTROY (struct evhttp_request *req); 868#void DESTROY (struct evhttp_request *req);
859 869
860#endif 870#endif
861 871
872#endif
862 873
863 874
864 875
865 876
866 877

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines