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

Comparing EV/EV.xs (file contents):
Revision 1.59 by root, Thu Nov 8 00:44:17 2007 UTC vs.
Revision 1.64 by root, Mon Nov 12 00:31:08 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;
116{ 122{
117 struct ev_watcher *w = (struct ev_watcher *)w_; 123 struct ev_watcher *w = (struct ev_watcher *)w_;
118 124
119 SvREFCNT_dec (w->fh ); w->fh = 0; 125 SvREFCNT_dec (w->fh ); w->fh = 0;
120 SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; 126 SvREFCNT_dec (w->cb_sv); w->cb_sv = 0;
127 SvREFCNT_dec (w->data ); w->data = 0;
121} 128}
122 129
123static SV * 130static SV *
124e_bless (struct ev_watcher *w, HV *stash) 131e_bless (struct ev_watcher *w, HV *stash)
125{ 132{
225} 232}
226 233
227///////////////////////////////////////////////////////////////////////////// 234/////////////////////////////////////////////////////////////////////////////
228// DNS 235// DNS
229 236
230#ifndef WIN32 237#ifndef _WIN32
231static void 238static void
232dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) 239dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg)
233{ 240{
234 dSP; 241 dSP;
235 SV *cb = (SV *)arg; 242 SV *cb = (SV *)arg;
373 evapi.child_stop = ev_child_stop; 380 evapi.child_stop = ev_child_stop;
374 381
375 sv_setiv (sv, (IV)&evapi); 382 sv_setiv (sv, (IV)&evapi);
376 SvREADONLY_on (sv); 383 SvREADONLY_on (sv);
377 } 384 }
378#ifndef WIN32 385#ifndef _WIN32
379 pthread_atfork (0, 0, ev_default_fork); 386 pthread_atfork (0, 0, ev_default_fork);
380#endif 387#endif
381} 388}
382 389
383NV ev_now () 390NV ev_now ()
427 CHECK_REPEAT (interval); 434 CHECK_REPEAT (interval);
428 CODE: 435 CODE:
429{ 436{
430 struct ev_periodic *w; 437 struct ev_periodic *w;
431 w = e_new (sizeof (struct ev_periodic), cb); 438 w = e_new (sizeof (struct ev_periodic), cb);
432 w->fh = SvOK (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 439 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
433 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); 440 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0);
434 RETVAL = e_bless ((struct ev_watcher *)w, stash_periodic); 441 RETVAL = e_bless ((struct ev_watcher *)w, stash_periodic);
435 if (!ix) ev_periodic_start (w); 442 if (!ix) ev_periodic_start (w);
436} 443}
437 OUTPUT: 444 OUTPUT:
499{ 506{
500 RETVAL = newSVsv (w->cb_sv); 507 RETVAL = newSVsv (w->cb_sv);
501 508
502 if (items > 1) 509 if (items > 1)
503 sv_setsv (w->cb_sv, new_cb); 510 sv_setsv (w->cb_sv, new_cb);
511}
512 OUTPUT:
513 RETVAL
514
515SV *data (struct ev_watcher *w, SV *new_data = 0)
516 CODE:
517{
518 RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef;
504} 519}
505 OUTPUT: 520 OUTPUT:
506 RETVAL 521 RETVAL
507 522
508void trigger (struct ev_watcher *w, int revents = EV_NONE) 523void trigger (struct ev_watcher *w, int revents = EV_NONE)
786 CODE: 801 CODE:
787 RETVAL = ix ? w->rpid : w->rstatus; 802 RETVAL = ix ? w->rpid : w->rstatus;
788 OUTPUT: 803 OUTPUT:
789 RETVAL 804 RETVAL
790 805
791#ifndef WIN32 806#ifndef _WIN32
792 807
793MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ 808MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_
794 809
795BOOT: 810BOOT:
796{ 811{
867 882
868int evdns_set_option (char *option, char *val, int flags) 883int evdns_set_option (char *option, char *val, int flags)
869 884
870int evdns_resolv_conf_parse (int flags, const char *filename) 885int evdns_resolv_conf_parse (int flags, const char *filename)
871 886
872#ifdef MS_WINDOWS 887#ifdef _WIN32
873 888
874int evdns_config_windows_nameservers () 889int evdns_config_windows_nameservers ()
875 890
876#endif 891#endif
877 892

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines