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

Comparing Async-Interrupt/Interrupt.xs (file contents):
Revision 1.4 by root, Thu Jul 2 16:12:40 2009 UTC vs.
Revision 1.5 by root, Fri Jul 3 21:11:22 2009 UTC

5typedef volatile sig_atomic_t atomic_t; 5typedef volatile sig_atomic_t atomic_t;
6 6
7static int *sig_pending, *psig_pend; /* make local copies because of missing THX */ 7static int *sig_pending, *psig_pend; /* make local copies because of missing THX */
8static Sighandler_t old_sighandler; 8static Sighandler_t old_sighandler;
9static atomic_t async_pending; 9static atomic_t async_pending;
10
11#define PERL_VERSION_ATLEAST(a,b,c) \
12 (PERL_REVISION > (a) \
13 || (PERL_REVISION == (a) \
14 && (PERL_VERSION > (b) \
15 || (PERL_VERSION == (b) && PERL_SUBVERSION >= (c)))))
16
17#if defined(HAS_SIGACTION) && defined(SA_SIGINFO)
18# define HAS_SA_SIGINFO 1
19#endif
20
21#if !PERL_VERSION_ATLEAST(5,10,0)
22# undef HAS_SA_SIGINFO
23#endif
10 24
11static int 25static int
12extract_fd (SV *fh, int wr) 26extract_fd (SV *fh, int wr)
13{ 27{
14 int fd = PerlIO_fileno (wr ? IoOFP (sv_2io (fh)) : IoIFP (sv_2io (fh))); 28 int fd = PerlIO_fileno (wr ? IoOFP (sv_2io (fh)) : IoIFP (sv_2io (fh)));
147 if (async->pending && !async->blocked) 161 if (async->pending && !async->blocked)
148 handle_async (async); 162 handle_async (async);
149 } 163 }
150} 164}
151 165
152#if defined(HAS_SIGACTION) && defined(SA_SIGINFO) 166#if HAS_SA_SIGINFO
153static Signal_t async_sighandler (int signum, siginfo_t *si, void *sarg) 167static Signal_t async_sighandler (int signum, siginfo_t *si, void *sarg)
154{ 168{
155 if (signum == 9) 169 if (signum == 9)
156 handle_asyncs (); 170 handle_asyncs ();
157 else 171 else
193 207
194SV * 208SV *
195_alloc (SV *cb, void *c_cb, void *c_arg, SV *fh_r, SV *fh_w) 209_alloc (SV *cb, void *c_cb, void *c_arg, SV *fh_r, SV *fh_w)
196 CODE: 210 CODE:
197{ 211{
198 SV *cv = SvOK (cb) ? SvREFCNT_inc_NN (get_cb (cb)) : 0; 212 SV *cv = SvOK (cb) ? SvREFCNT_inc (get_cb (cb)) : 0;
199 int fd_r = SvOK (fh_r) ? extract_fd (fh_r, 0) : -1; 213 int fd_r = SvOK (fh_r) ? extract_fd (fh_r, 0) : -1;
200 int fd_w = SvOK (fh_w) ? extract_fd (fh_w, 1) : -1; 214 int fd_w = SvOK (fh_w) ? extract_fd (fh_w, 1) : -1;
201 struct async *async; 215 struct async *async;
202 216
203 Newz (0, async, 1, struct async); 217 Newz (0, async, 1, struct async);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines