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

Comparing Coro-Multicore/schmorp.h (file contents):
Revision 1.1 by root, Sat Jun 27 17:59:10 2015 UTC vs.
Revision 1.4 by root, Tue Dec 3 07:12:28 2019 UTC

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
57typedef IV VAL64; 57typedef 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
61typedef NV VAL64; 62typedef 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/*
68VAL64 T_VAL64 70VAL64 T_VAL64
304 || addr.sin_port != adr2.sin_port) 306 || addr.sin_port != adr2.sin_port)
305 goto fail; 307 goto fail;
306 308
307 closesocket (listener); 309 closesocket (listener);
308 310
309#ifdef USE_SOCKETS_AS_HANDLES 311#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. 312 /* when select isn't winsocket, we also expect socket, connect, accept etc.
311 * to work on fds */ 313 * to work on fds */
312 filedes [0] = sock [0]; 314 filedes [0] = sock [0];
313 filedes [1] = sock [1]; 315 filedes [1] = sock [1];
314#else 316#else
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
367extern "C" { 372extern "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
377typedef struct { 383typedef 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));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines