… | |
… | |
55 | /* use NV for 32 bit perls as it allows larger offsets */ |
55 | /* use NV for 32 bit perls as it allows larger offsets */ |
56 | #if IVSIZE >= 8 |
56 | #if IVSIZE >= 8 |
57 | typedef IV VAL64; |
57 | typedef IV VAL64; |
58 | # define SvVAL64(sv) SvIV (sv) |
58 | # define SvVAL64(sv) SvIV (sv) |
59 | # define newSVval64(i64) newSViv (i64) |
59 | # define newSVval64(i64) newSViv (i64) |
|
|
60 | # define sv_setval64(sv,i64) sv_setiv ((sv), (i64)) |
60 | #else |
61 | #else |
61 | typedef NV VAL64; |
62 | typedef NV VAL64; |
62 | # define SvVAL64(sv) SvNV (sv) |
63 | # define SvVAL64(sv) SvNV (sv) |
63 | # define newSVval64(i64) newSVnv (i64) |
64 | # define newSVval64(i64) newSVnv (i64) |
|
|
65 | # define sv_setval64(sv,i64) sv_setnv ((sv), (i64)) |
64 | #endif |
66 | #endif |
65 | |
67 | |
66 | /* typemap for the above */ |
68 | /* typemap for the above */ |
67 | /* |
69 | /* |
68 | VAL64 T_VAL64 |
70 | VAL64 T_VAL64 |
… | |
… | |
357 | || fcntl (fd, F_SETFD, FD_CLOEXEC); |
359 | || fcntl (fd, F_SETFD, FD_CLOEXEC); |
358 | } |
360 | } |
359 | |
361 | |
360 | #endif |
362 | #endif |
361 | |
363 | |
|
|
364 | #if HAVE_EVENTFD |
|
|
365 | # include <sys/eventfd.h> |
|
|
366 | #else |
362 | #if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) |
367 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) |
363 | # define SCHMORP_H_HAVE_EVENTFD 1 |
368 | # define SCHMORP_H_HAVE_EVENTFD 1 |
364 | /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ |
369 | /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ |
365 | # include <stdint.h> |
370 | # include <stdint.h> |
366 | # ifdef __cplusplus |
371 | # ifdef __cplusplus |
367 | extern "C" { |
372 | extern "C" { |
368 | # endif |
373 | # endif |
369 | int eventfd (unsigned int initval, int flags); |
374 | int eventfd (unsigned int initval, int flags); |
370 | # ifdef __cplusplus |
375 | # ifdef __cplusplus |
371 | } |
376 | } |
372 | # endif |
377 | # endif |
373 | #else |
378 | # else |
374 | # define eventfd(initval,flags) -1 |
379 | # define eventfd(initval,flags) -1 |
|
|
380 | # endif |
375 | #endif |
381 | #endif |
376 | |
382 | |
377 | typedef struct { |
383 | typedef struct { |
378 | int fd[2]; /* read, write fd, might be equal */ |
384 | int fd[2]; /* read, write fd, might be equal */ |
379 | int len; /* write length (1 pipe/socket, 8 eventfd) */ |
385 | int len; /* write length (1 pipe/socket, 8 eventfd) */ |
… | |
… | |
436 | * incompetent windows programmers - is this redundant? |
442 | * incompetent windows programmers - is this redundant? |
437 | */ |
443 | */ |
438 | DWORD dummy; |
444 | DWORD dummy; |
439 | WriteFile (S_TO_HANDLE (epp->fd [1]), (LPCVOID)&dummy, 1, &dummy, 0); |
445 | WriteFile (S_TO_HANDLE (epp->fd [1]), (LPCVOID)&dummy, 1, &dummy, 0); |
440 | #else |
446 | #else |
441 | # if SCHMORP_H_HAVE_EVENTFD |
|
|
442 | static uint64_t counter = 1; |
447 | static uint64_t counter = 1; |
443 | # else |
|
|
444 | static char counter [8]; |
|
|
445 | # endif |
|
|
446 | /* some modules accept fd's from outside, support eventfd here */ |
448 | /* some modules accept fd's from outside, support eventfd here */ |
447 | if (write (epp->fd [1], &counter, epp->len) < 0 |
449 | if (write (epp->fd [1], &counter, epp->len) < 0 |
448 | && errno == EINVAL |
450 | && errno == EINVAL |
449 | && epp->len != 8) |
451 | && epp->len != 8) |
450 | write (epp->fd [1], &counter, (epp->len = 8)); |
452 | write (epp->fd [1], &counter, (epp->len = 8)); |