… | |
… | |
232 | } |
232 | } |
233 | |
233 | |
234 | /*****************************************************************************/ |
234 | /*****************************************************************************/ |
235 | /* portable pipe/socketpair */ |
235 | /* portable pipe/socketpair */ |
236 | |
236 | |
237 | #ifdef USE_SOCKETS_AS_HANDLES |
237 | #if defined(USE_SOCKETS_AS_HANDLES) || PERL_VERSION_ATLEAST(5,18,0) |
238 | # define S_TO_HANDLE(x) ((HANDLE)win32_get_osfhandle (x)) |
238 | # define S_TO_HANDLE(x) ((HANDLE)win32_get_osfhandle (x)) |
239 | #else |
239 | #else |
240 | # define S_TO_HANDLE(x) ((HANDLE)x) |
240 | # define S_TO_HANDLE(x) ((HANDLE)x) |
241 | #endif |
241 | #endif |
242 | |
242 | |
… | |
… | |
304 | || addr.sin_port != adr2.sin_port) |
304 | || addr.sin_port != adr2.sin_port) |
305 | goto fail; |
305 | goto fail; |
306 | |
306 | |
307 | closesocket (listener); |
307 | closesocket (listener); |
308 | |
308 | |
309 | #ifdef USE_SOCKETS_AS_HANDLES |
309 | #if defined(USE_SOCKETS_AS_HANDLES) || PERL_VERSION_ATLEAST(5,18,0) |
310 | /* when select isn't winsocket, we also expect socket, connect, accept etc. |
310 | /* when select isn't winsocket, we also expect socket, connect, accept etc. |
311 | * to work on fds */ |
311 | * to work on fds */ |
312 | filedes [0] = sock [0]; |
312 | filedes [0] = sock [0]; |
313 | filedes [1] = sock [1]; |
313 | filedes [1] = sock [1]; |
314 | #else |
314 | #else |
… | |
… | |
357 | || fcntl (fd, F_SETFD, FD_CLOEXEC); |
357 | || fcntl (fd, F_SETFD, FD_CLOEXEC); |
358 | } |
358 | } |
359 | |
359 | |
360 | #endif |
360 | #endif |
361 | |
361 | |
|
|
362 | #if HAVE_EVENTFD |
|
|
363 | # include <sys/eventfd.h> |
|
|
364 | #else |
362 | #if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) |
365 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) |
363 | # define SCHMORP_H_HAVE_EVENTFD 1 |
366 | # define SCHMORP_H_HAVE_EVENTFD 1 |
364 | /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ |
367 | /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ |
365 | # include <stdint.h> |
368 | # include <stdint.h> |
366 | # ifdef __cplusplus |
369 | # ifdef __cplusplus |
367 | extern "C" { |
370 | extern "C" { |
368 | # endif |
371 | # endif |
369 | int eventfd (unsigned int initval, int flags); |
372 | int eventfd (unsigned int initval, int flags); |
370 | # ifdef __cplusplus |
373 | # ifdef __cplusplus |
371 | } |
374 | } |
372 | # endif |
375 | # endif |
373 | #else |
376 | # else |
374 | # define eventfd(initval,flags) -1 |
377 | # define eventfd(initval,flags) -1 |
|
|
378 | # endif |
375 | #endif |
379 | #endif |
376 | |
380 | |
377 | typedef struct { |
381 | typedef struct { |
378 | int fd[2]; /* read, write fd, might be equal */ |
382 | int fd[2]; /* read, write fd, might be equal */ |
379 | int len; /* write length (1 pipe/socket, 8 eventfd) */ |
383 | int len; /* write length (1 pipe/socket, 8 eventfd) */ |