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

Comparing libev/ev.c (file contents):
Revision 1.338 by root, Tue Mar 16 00:20:17 2010 UTC vs.
Revision 1.343 by root, Fri Apr 2 21:03:46 2010 UTC

77# ifndef EV_USE_REALTIME 77# ifndef EV_USE_REALTIME
78# define EV_USE_REALTIME 0 78# define EV_USE_REALTIME 0
79# endif 79# endif
80# endif 80# endif
81 81
82# if HAVE_NANOSLEEP
82# ifndef EV_USE_NANOSLEEP 83# ifndef EV_USE_NANOSLEEP
83# if HAVE_NANOSLEEP
84# define EV_USE_NANOSLEEP 1 84# define EV_USE_NANOSLEEP EV_FEATURE_OS
85# endif
85# else 86# else
87# undef EV_USE_NANOSLEEP
86# define EV_USE_NANOSLEEP 0 88# define EV_USE_NANOSLEEP 0
89# endif
90
91# if HAVE_SELECT && HAVE_SYS_SELECT_H
92# ifndef EV_USE_SELECT
93# define EV_USE_SELECT EV_FEATURE_BACKENDS
87# endif 94# endif
88# endif
89
90# ifndef EV_USE_SELECT
91# if HAVE_SELECT && HAVE_SYS_SELECT_H
92# define EV_USE_SELECT 1
93# else 95# else
96# undef EV_USE_SELECT
94# define EV_USE_SELECT 0 97# define EV_USE_SELECT 0
98# endif
99
100# if HAVE_POLL && HAVE_POLL_H
101# ifndef EV_USE_POLL
102# define EV_USE_POLL EV_FEATURE_BACKENDS
95# endif 103# endif
96# endif
97
98# ifndef EV_USE_POLL
99# if HAVE_POLL && HAVE_POLL_H
100# define EV_USE_POLL 1
101# else 104# else
105# undef EV_USE_POLL
102# define EV_USE_POLL 0 106# define EV_USE_POLL 0
107# endif
108
109# if HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H
110# ifndef EV_USE_EPOLL
111# define EV_USE_EPOLL EV_FEATURE_BACKENDS
103# endif 112# endif
113# else
114# undef EV_USE_EPOLL
115# define EV_USE_EPOLL 0
104# endif 116# endif
105 117
118# if HAVE_KQUEUE && HAVE_SYS_EVENT_H
106# ifndef EV_USE_EPOLL 119# ifndef EV_USE_KQUEUE
107# if HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H 120# define EV_USE_KQUEUE EV_FEATURE_BACKENDS
108# define EV_USE_EPOLL 1
109# else
110# define EV_USE_EPOLL 0
111# endif 121# endif
122# else
123# undef EV_USE_KQUEUE
124# define EV_USE_KQUEUE 0
112# endif 125# endif
113 126
114# ifndef EV_USE_KQUEUE 127# if HAVE_PORT_H && HAVE_PORT_CREATE
115# if HAVE_KQUEUE && HAVE_SYS_EVENT_H 128# ifndef EV_USE_PORT
116# define EV_USE_KQUEUE 1 129# define EV_USE_PORT EV_FEATURE_BACKENDS
117# else
118# define EV_USE_KQUEUE 0
119# endif 130# endif
120# endif
121
122# ifndef EV_USE_PORT
123# if HAVE_PORT_H && HAVE_PORT_CREATE
124# define EV_USE_PORT 1
125# else 131# else
132# undef EV_USE_PORT
126# define EV_USE_PORT 0 133# define EV_USE_PORT 0
134# endif
135
136# if HAVE_INOTIFY_INIT && HAVE_SYS_INOTIFY_H
137# ifndef EV_USE_INOTIFY
138# define EV_USE_INOTIFY EV_FEATURE_OS
127# endif 139# endif
128# endif
129
130# ifndef EV_USE_INOTIFY
131# if HAVE_INOTIFY_INIT && HAVE_SYS_INOTIFY_H
132# define EV_USE_INOTIFY 1
133# else 140# else
141# undef EV_USE_INOTIFY
134# define EV_USE_INOTIFY 0 142# define EV_USE_INOTIFY 0
143# endif
144
145# if HAVE_SIGNALFD && HAVE_SYS_SIGNALFD_H
146# ifndef EV_USE_SIGNALFD
147# define EV_USE_SIGNALFD EV_FEATURE_OS
135# endif 148# endif
136# endif
137
138# ifndef EV_USE_SIGNALFD
139# if HAVE_SIGNALFD && HAVE_SYS_SIGNALFD_H
140# define EV_USE_SIGNALFD 1
141# else 149# else
150# undef EV_USE_SIGNALFD
142# define EV_USE_SIGNALFD 0 151# define EV_USE_SIGNALFD 0
152# endif
153
154# if HAVE_EVENTFD
155# ifndef EV_USE_EVENTFD
156# define EV_USE_EVENTFD EV_FEATURE_OS
143# endif 157# endif
144# endif
145
146# ifndef EV_USE_EVENTFD
147# if HAVE_EVENTFD
148# define EV_USE_EVENTFD 1
149# else 158# else
159# undef EV_USE_EVENTFD
150# define EV_USE_EVENTFD 0 160# define EV_USE_EVENTFD 0
151# endif
152# endif 161# endif
153 162
154#endif 163#endif
155 164
156#include <math.h> 165#include <math.h>
435 444
436 445
437/**/ 446/**/
438 447
439#if EV_VERIFY >= 3 448#if EV_VERIFY >= 3
440# define EV_FREQUENT_CHECK ev_loop_verify (EV_A) 449# define EV_FREQUENT_CHECK ev_verify (EV_A)
441#else 450#else
442# define EV_FREQUENT_CHECK do { } while (0) 451# define EV_FREQUENT_CHECK do { } while (0)
443#endif 452#endif
444 453
445/* 454/*
1507#ifdef __APPLE__ 1516#ifdef __APPLE__
1508 /* only select works correctly on that "unix-certified" platform */ 1517 /* only select works correctly on that "unix-certified" platform */
1509 flags &= ~EVBACKEND_KQUEUE; /* horribly broken, even for sockets */ 1518 flags &= ~EVBACKEND_KQUEUE; /* horribly broken, even for sockets */
1510 flags &= ~EVBACKEND_POLL; /* poll is based on kqueue from 10.5 onwards */ 1519 flags &= ~EVBACKEND_POLL; /* poll is based on kqueue from 10.5 onwards */
1511#endif 1520#endif
1521#ifdef __FreeBSD__
1522 flags &= ~EVBACKEND_POLL; /* poll return value is unusable (http://forums.freebsd.org/archive/index.php/t-10270.html) */
1523#endif
1512 1524
1513 return flags; 1525 return flags;
1514} 1526}
1515 1527
1516unsigned int 1528unsigned int
1531 return backend; 1543 return backend;
1532} 1544}
1533 1545
1534#if EV_FEATURE_API 1546#if EV_FEATURE_API
1535unsigned int 1547unsigned int
1536ev_loop_count (EV_P) 1548ev_iteration (EV_P)
1537{ 1549{
1538 return loop_count; 1550 return loop_count;
1539} 1551}
1540 1552
1541unsigned int 1553unsigned int
1542ev_loop_depth (EV_P) 1554ev_depth (EV_P)
1543{ 1555{
1544 return loop_depth; 1556 return loop_depth;
1545} 1557}
1546 1558
1547void 1559void
1868} 1880}
1869#endif 1881#endif
1870 1882
1871#if EV_FEATURE_API 1883#if EV_FEATURE_API
1872void 1884void
1873ev_loop_verify (EV_P) 1885ev_verify (EV_P)
1874{ 1886{
1875#if EV_VERIFY 1887#if EV_VERIFY
1876 int i; 1888 int i;
1877 WL w; 1889 WL w;
1878 1890
2096 EV_FREQUENT_CHECK; 2108 EV_FREQUENT_CHECK;
2097 feed_reverse (EV_A_ (W)w); 2109 feed_reverse (EV_A_ (W)w);
2098 } 2110 }
2099 while (timercnt && ANHE_at (timers [HEAP0]) < mn_now); 2111 while (timercnt && ANHE_at (timers [HEAP0]) < mn_now);
2100 2112
2101 feed_reverse_done (EV_A_ EV_TIMEOUT); 2113 feed_reverse_done (EV_A_ EV_TIMER);
2102 } 2114 }
2103} 2115}
2104 2116
2105#if EV_PERIODIC_ENABLE 2117#if EV_PERIODIC_ENABLE
2106/* make periodics pending */ 2118/* make periodics pending */
2280 EV_INVOKE_PENDING; /* in case we recurse, ensure ordering stays nice and clean */ 2292 EV_INVOKE_PENDING; /* in case we recurse, ensure ordering stays nice and clean */
2281 2293
2282 do 2294 do
2283 { 2295 {
2284#if EV_VERIFY >= 2 2296#if EV_VERIFY >= 2
2285 ev_loop_verify (EV_A); 2297 ev_verify (EV_A);
2286#endif 2298#endif
2287 2299
2288#ifndef _WIN32 2300#ifndef _WIN32
2289 if (expect_false (curpid)) /* penalise the forking check even more */ 2301 if (expect_false (curpid)) /* penalise the forking check even more */
2290 if (expect_false (getpid () != curpid)) 2302 if (expect_false (getpid () != curpid))
3636{ 3648{
3637 struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once)); 3649 struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once));
3638 3650
3639 if (expect_false (!once)) 3651 if (expect_false (!once))
3640 { 3652 {
3641 cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg); 3653 cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMER, arg);
3642 return; 3654 return;
3643 } 3655 }
3644 3656
3645 once->cb = cb; 3657 once->cb = cb;
3646 once->arg = arg; 3658 once->arg = arg;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines