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

Comparing EV/EV.xs (file contents):
Revision 1.60 by root, Thu Nov 8 02:19:36 2007 UTC vs.
Revision 1.73 by root, Fri Nov 23 05:00:44 2007 UTC

9 9
10/* fix perl api breakage */ 10/* fix perl api breakage */
11#undef signal 11#undef signal
12#undef sigaction 12#undef sigaction
13 13
14#define EV_SELECT_USE_WIN32_HANDLES 0 14#define EV_SELECT_IS_WINSOCKET 0
15#ifdef _WIN32
15#define EV_SELECT_USE_FD_SET 0 16# define EV_SELECT_USE_FD_SET 0
17# define NFDBITS PERL_NFDBITS
18# define fd_mask Perl_fd_mask
19#endif
16/* due to bugs in OS X we have to use libev/ explicitly here */ 20/* due to bugs in OS X we have to use libev/ explicitly here */
17#include "libev/ev.c" 21#include "libev/ev.c"
18#include "event.c" 22#include "event.c"
19 23
20#ifndef WIN32 24#ifndef _WIN32
21#define DNS_USE_GETTIMEOFDAY_FOR_ID 1 25#define DNS_USE_GETTIMEOFDAY_FOR_ID 1
22#if !defined (WIN32) && !defined(__CYGWIN__) 26#if !defined (WIN32) && !defined(__CYGWIN__)
23# define HAVE_STRUCT_IN6_ADDR 1 27# define HAVE_STRUCT_IN6_ADDR 1
24#endif 28#endif
25#undef HAVE_STRTOK_R 29#undef HAVE_STRTOK_R
26#undef strtok_r 30#undef strtok_r
27#define strtok_r fake_strtok_r 31#define strtok_r fake_strtok_r
32#include "evdns.h"
28#include "evdns.c" 33#include "evdns.c"
29#endif 34#endif
30 35
31#ifndef WIN32 36#ifndef _WIN32
32# include <pthread.h> 37# include <pthread.h>
33#endif 38#endif
34 39
35typedef int Signal; 40typedef int Signal;
36 41
100 SvPOK_only (self); 105 SvPOK_only (self);
101 SvCUR_set (self, size); 106 SvCUR_set (self, size);
102 107
103 w = (struct ev_watcher *)SvPVX (self); 108 w = (struct ev_watcher *)SvPVX (self);
104 109
105 ev_watcher_init (w, e_cb); 110 ev_init (w, e_cb);
106 111
112 w->data = 0;
107 w->fh = 0; 113 w->fh = 0;
108 w->cb_sv = newSVsv (cb_sv); 114 w->cb_sv = newSVsv (cb_sv);
109 w->self = self; 115 w->self = self;
110 116
111 return (void *)w; 117 return (void *)w;
161 PUSHs (sv_self); 167 PUSHs (sv_self);
162 PUSHs (sv_events); 168 PUSHs (sv_events);
163 169
164 PUTBACK; 170 PUTBACK;
165 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); 171 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL);
166 SP = PL_stack_base + mark; PUTBACK;
167 172
168 SvREFCNT_dec (sv_self); 173 SvREFCNT_dec (sv_self);
169 SvREFCNT_dec (sv_status); 174 SvREFCNT_dec (sv_status);
170 175
171 if (sv_events_cache) 176 if (sv_events_cache)
176 if (SvTRUE (ERRSV)) 181 if (SvTRUE (ERRSV))
177 { 182 {
178 PUSHMARK (SP); 183 PUSHMARK (SP);
179 PUTBACK; 184 PUTBACK;
180 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); 185 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
181 SP = PL_stack_base + mark; PUTBACK;
182 } 186 }
187
188 SP = PL_stack_base + mark;
189 PUTBACK;
183} 190}
184 191
185static ev_tstamp 192static ev_tstamp
186e_periodic_cb (struct ev_periodic *w, ev_tstamp now) 193e_periodic_cb (struct ev_periodic *w, ev_tstamp now)
187{ 194{
226} 233}
227 234
228///////////////////////////////////////////////////////////////////////////// 235/////////////////////////////////////////////////////////////////////////////
229// DNS 236// DNS
230 237
231#ifndef WIN32 238#ifndef _WIN32
232static void 239static void
233dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) 240dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg)
234{ 241{
235 dSP; 242 dSP;
236 SV *cb = (SV *)arg; 243 SV *cb = (SV *)arg;
314 const_iv (EV_, CHECK) 321 const_iv (EV_, CHECK)
315 const_iv (EV_, ERROR) 322 const_iv (EV_, ERROR)
316 323
317 const_iv (EV, LOOP_ONESHOT) 324 const_iv (EV, LOOP_ONESHOT)
318 const_iv (EV, LOOP_NONBLOCK) 325 const_iv (EV, LOOP_NONBLOCK)
326 const_iv (EV, UNLOOP_ONE)
327 const_iv (EV, UNLOOP_ALL)
319 328
320 const_iv (EV, METHOD_AUTO)
321 const_iv (EV, METHOD_SELECT) 329 const_iv (EV, BACKEND_SELECT)
322 const_iv (EV, METHOD_POLL) 330 const_iv (EV, BACKEND_POLL)
323 const_iv (EV, METHOD_EPOLL) 331 const_iv (EV, BACKEND_EPOLL)
324 const_iv (EV, METHOD_KQUEUE) 332 const_iv (EV, BACKEND_KQUEUE)
325 const_iv (EV, METHOD_DEVPOLL) 333 const_iv (EV, BACKEND_DEVPOLL)
326 const_iv (EV, METHOD_PORT) 334 const_iv (EV, BACKEND_PORT)
327 const_iv (EV, METHOD_ANY) 335 const_iv (EV, FLAG_AUTO)
336 const_iv (EV, FLAG_NOENV)
328 }; 337 };
329 338
330 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 339 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
331 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 340 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
332 341
348 evapi.ver = EV_API_VERSION; 357 evapi.ver = EV_API_VERSION;
349 evapi.rev = EV_API_REVISION; 358 evapi.rev = EV_API_REVISION;
350 evapi.sv_fileno = sv_fileno; 359 evapi.sv_fileno = sv_fileno;
351 evapi.sv_signum = sv_signum; 360 evapi.sv_signum = sv_signum;
352 evapi.now = ev_now; 361 evapi.now = ev_now;
353 evapi.method = ev_method; 362 evapi.backend = ev_backend;
354 evapi.unloop = ev_unloop; 363 evapi.unloop = ev_unloop;
355 evapi.time = ev_time; 364 evapi.time = ev_time;
356 evapi.loop = ev_loop; 365 evapi.loop = ev_loop;
357 evapi.once = ev_once; 366 evapi.once = ev_once;
358 evapi.io_start = ev_io_start; 367 evapi.io_start = ev_io_start;
374 evapi.child_stop = ev_child_stop; 383 evapi.child_stop = ev_child_stop;
375 384
376 sv_setiv (sv, (IV)&evapi); 385 sv_setiv (sv, (IV)&evapi);
377 SvREADONLY_on (sv); 386 SvREADONLY_on (sv);
378 } 387 }
379#ifndef WIN32 388#ifndef _WIN32
380 pthread_atfork (0, 0, ev_default_fork); 389 pthread_atfork (0, 0, ev_default_fork);
381#endif 390#endif
382} 391}
383 392
384NV ev_now () 393NV ev_now ()
385 394
386int ev_method () 395int ev_method ()
387 396
388NV ev_time () 397NV ev_time ()
389 398
390int ev_default_loop (int methods = EVMETHOD_AUTO) 399int ev_default_loop (int methods = ev_supported_methods ())
391 400
392void ev_loop (int flags = 0) 401void ev_loop (int flags = 0)
393 402
394void ev_unloop (int how = 1) 403void ev_unloop (int how = 1)
395 404
478 OUTPUT: 487 OUTPUT:
479 RETVAL 488 RETVAL
480 489
481struct ev_child *child (int pid, SV *cb) 490struct ev_child *child (int pid, SV *cb)
482 ALIAS: 491 ALIAS:
483 check_ns = 1 492 child_ns = 1
484 CODE: 493 CODE:
485 RETVAL = e_new (sizeof (struct ev_child), cb); 494 RETVAL = e_new (sizeof (struct ev_child), cb);
486 ev_child_set (RETVAL, pid); 495 ev_child_set (RETVAL, pid);
487 if (!ix) ev_child_start (RETVAL); 496 if (!ix) ev_child_start (RETVAL);
488 OUTPUT: 497 OUTPUT:
795 CODE: 804 CODE:
796 RETVAL = ix ? w->rpid : w->rstatus; 805 RETVAL = ix ? w->rpid : w->rstatus;
797 OUTPUT: 806 OUTPUT:
798 RETVAL 807 RETVAL
799 808
800#ifndef WIN32 809#ifndef _WIN32
801 810
802MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ 811MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_
803 812
804BOOT: 813BOOT:
805{ 814{
876 885
877int evdns_set_option (char *option, char *val, int flags) 886int evdns_set_option (char *option, char *val, int flags)
878 887
879int evdns_resolv_conf_parse (int flags, const char *filename) 888int evdns_resolv_conf_parse (int flags, const char *filename)
880 889
881#ifdef MS_WINDOWS 890#ifdef _WIN32
882 891
883int evdns_config_windows_nameservers () 892int evdns_config_windows_nameservers ()
884 893
885#endif 894#endif
886 895

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines