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

Comparing Async-Interrupt/schmorp.h (file contents):
Revision 1.4 by root, Fri Jul 17 21:04:45 2009 UTC vs.
Revision 1.7 by root, Wed Aug 5 11:51:53 2009 UTC

20 (PERL_REVISION > (a) \ 20 (PERL_REVISION > (a) \
21 || (PERL_REVISION == (a) \ 21 || (PERL_REVISION == (a) \
22 && (PERL_VERSION > (b) \ 22 && (PERL_VERSION > (b) \
23 || (PERL_VERSION == (b) && PERL_SUBVERSION >= (c))))) 23 || (PERL_VERSION == (b) && PERL_SUBVERSION >= (c)))))
24 24
25#ifndef PERL_MAGIC_ext
26# define PERL_MAGIC_ext '~'
27#endif
28
25#if !PERL_VERSION_ATLEAST (5,6,0) 29#if !PERL_VERSION_ATLEAST (5,6,0)
26# ifndef PL_ppaddr 30# ifndef PL_ppaddr
27# define PL_ppaddr ppaddr 31# define PL_ppaddr ppaddr
28# endif 32# endif
29# ifndef call_sv 33# ifndef call_sv
209/* taken almost verbatim from libev's ev_win32.c */ 213/* taken almost verbatim from libev's ev_win32.c */
210/* oh, the humanity! */ 214/* oh, the humanity! */
211static int 215static int
212s_pipe (int filedes [2]) 216s_pipe (int filedes [2])
213{ 217{
218 dTHX;
219
214 struct sockaddr_in addr = { 0 }; 220 struct sockaddr_in addr = { 0 };
215 int addr_size = sizeof (addr); 221 int addr_size = sizeof (addr);
216 struct sockaddr_in adr2; 222 struct sockaddr_in adr2;
217 int adr2_size = sizeof (adr2); 223 int adr2_size = sizeof (adr2);
218 SOCKET listener; 224 SOCKET listener;
359 return -1; 365 return -1;
360 366
361 if (s_fd_prepare (ep.fd [0]) 367 if (s_fd_prepare (ep.fd [0])
362 || s_fd_prepare (ep.fd [1])) 368 || s_fd_prepare (ep.fd [1]))
363 { 369 {
370 dTHX;
371
364 close (ep.fd [0]); 372 close (ep.fd [0]);
365 close (ep.fd [1]); 373 close (ep.fd [1]);
366 return -1; 374 return -1;
367 } 375 }
368 376
374} 382}
375 383
376static void 384static void
377s_epipe_destroy (s_epipe *epp) 385s_epipe_destroy (s_epipe *epp)
378{ 386{
387 dTHX;
388
379 close (epp->fd [0]); 389 close (epp->fd [0]);
380 390
381 if (epp->fd [1] != epp->fd [0]) 391 if (epp->fd [1] != epp->fd [0])
382 close (epp->fd [1]); 392 close (epp->fd [1]);
383 393
406} 416}
407 417
408static void 418static void
409s_epipe_drain (s_epipe *epp) 419s_epipe_drain (s_epipe *epp)
410{ 420{
421 dTHX;
411 char buf [9]; 422 char buf [9];
412 423
413#ifdef _WIN32 424#ifdef _WIN32
414 recv (epp->fd [0], buf, sizeof (buf), 0); 425 recv (epp->fd [0], buf, sizeof (buf), 0);
415#else 426#else
419 430
420/* like new, but dups over old */ 431/* like new, but dups over old */
421static int 432static int
422s_epipe_renew (s_epipe *epp) 433s_epipe_renew (s_epipe *epp)
423{ 434{
435 dTHX;
424 s_epipe epn; 436 s_epipe epn;
425 437
426 if (epp->fd [1] != epp->fd [0]) 438 if (epp->fd [1] != epp->fd [0])
427 close (epp->fd [1]); 439 close (epp->fd [1]);
428 440
448#define s_epipe_fd(epp) ((epp)->fd [0]) 460#define s_epipe_fd(epp) ((epp)->fd [0])
449 461
450static int 462static int
451s_epipe_wait (s_epipe *epp) 463s_epipe_wait (s_epipe *epp)
452{ 464{
465 dTHX;
453#ifdef _WIN32 466#ifdef _WIN32
454 fd_set rfd; 467 fd_set rfd;
455 int fd = s_epipe_fd (epp); 468 int fd = s_epipe_fd (epp);
456 469
457 FD_ZERO (&rfd); 470 FD_ZERO (&rfd);
463 struct pollfd pfd; 476 struct pollfd pfd;
464 477
465 pfd.fd = s_epipe_fd (epp); 478 pfd.fd = s_epipe_fd (epp);
466 pfd.events = POLLIN; 479 pfd.events = POLLIN;
467 480
468 return poll (&pfd, 1, 0); 481 return poll (&pfd, 1, -1);
469#endif 482#endif
470} 483}
471 484
472#endif 485#endif
473 486

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines