ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.312 by root, Wed Aug 12 18:48:17 2009 UTC vs.
Revision 1.314 by root, Wed Aug 26 17:31:20 2009 UTC

302# define EV_USE_EVENTFD 0 302# define EV_USE_EVENTFD 0
303# endif 303# endif
304#endif 304#endif
305 305
306#ifndef EV_USE_SIGNALFD 306#ifndef EV_USE_SIGNALFD
307# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9)) 307# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7))
308# define EV_USE_SIGNALFD 1 308# define EV_USE_SIGNALFD 1
309# else 309# else
310# define EV_USE_SIGNALFD 0 310# define EV_USE_SIGNALFD 0
311# endif 311# endif
312#endif 312#endif
402} 402}
403# endif 403# endif
404#endif 404#endif
405 405
406#if EV_USE_SIGNALFD 406#if EV_USE_SIGNALFD
407# include <sys/signalfd.h> 407/* our minimum requirement is glibc 2.7 which has the stub, but not the header */
408# include <stdint.h>
409# ifndef SFD_NONBLOCK
410# define SFD_NONBLOCK O_NONBLOCK
408#endif 411# endif
412# ifndef SFD_CLOEXEC
413# ifdef O_CLOEXEC
414# define SFD_CLOEXEC O_CLOEXEC
415# else
416# define SFD_CLOEXEC 02000000
417# endif
418# endif
419# ifdef __cplusplus
420extern "C" {
421# endif
422int signalfd (int fd, const sigset_t *mask, int flags);
423
424struct signalfd_siginfo
425{
426 uint32_t ssi_signo;
427 char pad[128 - sizeof (uint32_t)];
428};
429# ifdef __cplusplus
430}
431# endif
432#endif
433
409 434
410/**/ 435/**/
411 436
412#if EV_VERIFY >= 3 437#if EV_VERIFY >= 3
413# define EV_FREQUENT_CHECK ev_loop_verify (EV_A) 438# define EV_FREQUENT_CHECK ev_loop_verify (EV_A)
476 501
477#if EV_USE_MONOTONIC 502#if EV_USE_MONOTONIC
478static EV_ATOMIC_T have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ 503static EV_ATOMIC_T have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */
479#endif 504#endif
480 505
506#ifndef EV_FD_TO_WIN32_HANDLE
507# define EV_FD_TO_WIN32_HANDLE(fd) _get_osfhandle (fd)
508#endif
509#ifndef EV_WIN32_HANDLE_TO_FD
510# define EV_WIN32_HANDLE_TO_FD(handle) _open_osfhandle (fd, 0)
511#endif
512#ifndef EV_WIN32_CLOSE_FD
513# define EV_WIN32_CLOSE_FD(fd) close (fd)
514#endif
515
481#ifdef _WIN32 516#ifdef _WIN32
482# include "ev_win32.c" 517# include "ev_win32.c"
483#endif 518#endif
484 519
485/*****************************************************************************/ 520/*****************************************************************************/
876 911
877#if EV_SELECT_IS_WINSOCKET 912#if EV_SELECT_IS_WINSOCKET
878 if (events) 913 if (events)
879 { 914 {
880 unsigned long arg; 915 unsigned long arg;
881 #ifdef EV_FD_TO_WIN32_HANDLE
882 anfd->handle = EV_FD_TO_WIN32_HANDLE (fd); 916 anfd->handle = EV_FD_TO_WIN32_HANDLE (fd);
883 #else
884 anfd->handle = _get_osfhandle (fd);
885 #endif
886 assert (("libev: only socket fds supported in this configuration", ioctlsocket (anfd->handle, FIONREAD, &arg) == 0)); 917 assert (("libev: only socket fds supported in this configuration", ioctlsocket (anfd->handle, FIONREAD, &arg) == 0));
887 } 918 }
888#endif 919#endif
889 920
890 { 921 {
1621 close (evfd); 1652 close (evfd);
1622#endif 1653#endif
1623 1654
1624 if (evpipe [0] >= 0) 1655 if (evpipe [0] >= 0)
1625 { 1656 {
1626 close (evpipe [0]); 1657 EV_WIN32_CLOSE_FD (evpipe [0]);
1627 close (evpipe [1]); 1658 EV_WIN32_CLOSE_FD (evpipe [1]);
1628 } 1659 }
1629 } 1660 }
1630 1661
1631#if EV_USE_SIGNALFD 1662#if EV_USE_SIGNALFD
1632 if (ev_is_active (&sigfd_w)) 1663 if (ev_is_active (&sigfd_w))
1728 close (evfd); 1759 close (evfd);
1729#endif 1760#endif
1730 1761
1731 if (evpipe [0] >= 0) 1762 if (evpipe [0] >= 0)
1732 { 1763 {
1733 close (evpipe [0]); 1764 EV_WIN32_CLOSE_FD (evpipe [0]);
1734 close (evpipe [1]); 1765 EV_WIN32_CLOSE_FD (evpipe [1]);
1735 } 1766 }
1736 1767
1737 evpipe_init (EV_A); 1768 evpipe_init (EV_A);
1738 /* now iterate over everything, in case we missed something */ 1769 /* now iterate over everything, in case we missed something */
1739 pipecb (EV_A_ &pipe_w, EV_READ); 1770 pipecb (EV_A_ &pipe_w, EV_READ);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines