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

Comparing libev/ev.c (file contents):
Revision 1.58 by root, Sun Nov 4 16:52:52 2007 UTC vs.
Revision 1.59 by root, Sun Nov 4 18:15:16 2007 UTC

26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31#ifndef EV_EMBED 31#ifndef EV_STANDALONE
32# include "config.h" 32# include "config.h"
33#endif 33#endif
34 34
35#include <math.h> 35#include <math.h>
36#include <stdlib.h> 36#include <stdlib.h>
58 58
59#ifndef EV_USE_SELECT 59#ifndef EV_USE_SELECT
60# define EV_USE_SELECT 1 60# define EV_USE_SELECT 1
61#endif 61#endif
62 62
63#ifndef EV_USEV_POLL 63#ifndef EV_USE_POLL
64# define EV_USEV_POLL 0 /* poll is usually slower than select, and not as well tested */ 64# define EV_USE_POLL 0 /* poll is usually slower than select, and not as well tested */
65#endif 65#endif
66 66
67#ifndef EV_USE_EPOLL 67#ifndef EV_USE_EPOLL
68# define EV_USE_EPOLL 0 68# define EV_USE_EPOLL 0
69#endif 69#endif
93#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */ 93#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */
94#define MAX_BLOCKTIME 59.731 /* never wait longer than this time (to detect time jumps) */ 94#define MAX_BLOCKTIME 59.731 /* never wait longer than this time (to detect time jumps) */
95#define PID_HASHSIZE 16 /* size of pid hash table, must be power of two */ 95#define PID_HASHSIZE 16 /* size of pid hash table, must be power of two */
96/*#define CLEANUP_INTERVAL 300. /* how often to try to free memory and re-check fds */ 96/*#define CLEANUP_INTERVAL 300. /* how often to try to free memory and re-check fds */
97 97
98#ifndef EV_EMBED
99# include "ev.h" 98#include "ev.h"
100#endif
101 99
102#if __GNUC__ >= 3 100#if __GNUC__ >= 3
103# define expect(expr,value) __builtin_expect ((expr),(value)) 101# define expect(expr,value) __builtin_expect ((expr),(value))
104# define inline inline 102# define inline inline
105#else 103#else
411static ANSIG *signals; 409static ANSIG *signals;
412static int signalmax; 410static int signalmax;
413 411
414static int sigpipe [2]; 412static int sigpipe [2];
415static sig_atomic_t volatile gotsig; 413static sig_atomic_t volatile gotsig;
414static struct ev_io sigev;
416 415
417static void 416static void
418signals_init (ANSIG *base, int count) 417signals_init (ANSIG *base, int count)
419{ 418{
420 while (count--) 419 while (count--)
477} 476}
478 477
479/*****************************************************************************/ 478/*****************************************************************************/
480 479
481#ifndef WIN32 480#ifndef WIN32
481
482static struct ev_child *childs [PID_HASHSIZE];
483static struct ev_signal childev;
482 484
483#ifndef WCONTINUED 485#ifndef WCONTINUED
484# define WCONTINUED 0 486# define WCONTINUED 0
485#endif 487#endif
486 488
522# include "ev_kqueue.c" 524# include "ev_kqueue.c"
523#endif 525#endif
524#if EV_USE_EPOLL 526#if EV_USE_EPOLL
525# include "ev_epoll.c" 527# include "ev_epoll.c"
526#endif 528#endif
527#if EV_USEV_POLL 529#if EV_USE_POLL
528# include "ev_poll.c" 530# include "ev_poll.c"
529#endif 531#endif
530#if EV_USE_SELECT 532#if EV_USE_SELECT
531# include "ev_select.c" 533# include "ev_select.c"
532#endif 534#endif
590 if (!method && (methods & EVMETHOD_KQUEUE)) method = kqueue_init (EV_A_ methods); 592 if (!method && (methods & EVMETHOD_KQUEUE)) method = kqueue_init (EV_A_ methods);
591#endif 593#endif
592#if EV_USE_EPOLL 594#if EV_USE_EPOLL
593 if (!method && (methods & EVMETHOD_EPOLL )) method = epoll_init (EV_A_ methods); 595 if (!method && (methods & EVMETHOD_EPOLL )) method = epoll_init (EV_A_ methods);
594#endif 596#endif
595#if EV_USEV_POLL 597#if EV_USE_POLL
596 if (!method && (methods & EVMETHOD_POLL )) method = poll_init (EV_A_ methods); 598 if (!method && (methods & EVMETHOD_POLL )) method = poll_init (EV_A_ methods);
597#endif 599#endif
598#if EV_USE_SELECT 600#if EV_USE_SELECT
599 if (!method && (methods & EVMETHOD_SELECT)) method = select_init (EV_A_ methods); 601 if (!method && (methods & EVMETHOD_SELECT)) method = select_init (EV_A_ methods);
600#endif 602#endif
608 if (method == EVMETHOD_KQUEUE) kqueue_destroy (EV_A); 610 if (method == EVMETHOD_KQUEUE) kqueue_destroy (EV_A);
609#endif 611#endif
610#if EV_USE_EPOLL 612#if EV_USE_EPOLL
611 if (method == EVMETHOD_EPOLL ) epoll_destroy (EV_A); 613 if (method == EVMETHOD_EPOLL ) epoll_destroy (EV_A);
612#endif 614#endif
613#if EV_USEV_POLL 615#if EV_USE_POLL
614 if (method == EVMETHOD_POLL ) poll_destroy (EV_A); 616 if (method == EVMETHOD_POLL ) poll_destroy (EV_A);
615#endif 617#endif
616#if EV_USE_SELECT 618#if EV_USE_SELECT
617 if (method == EVMETHOD_SELECT) select_destroy (EV_A); 619 if (method == EVMETHOD_SELECT) select_destroy (EV_A);
618#endif 620#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines