… | |
… | |
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! */ |
211 | static int |
215 | static int |
212 | s_pipe (int filedes [2]) |
216 | s_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 | |
376 | static void |
384 | static void |
377 | s_epipe_destroy (s_epipe *epp) |
385 | s_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 | |
408 | static void |
418 | static void |
409 | s_epipe_drain (s_epipe *epp) |
419 | s_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 */ |
421 | static int |
432 | static int |
422 | s_epipe_renew (s_epipe *epp) |
433 | s_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 | |
450 | static int |
462 | static int |
451 | s_epipe_wait (s_epipe *epp) |
463 | s_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 | |