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

Comparing libev/ev.c (file contents):
Revision 1.42 by root, Fri Nov 2 20:05:05 2007 UTC vs.
Revision 1.45 by root, Sat Nov 3 09:19:58 2007 UTC

42#include <stdio.h> 42#include <stdio.h>
43 43
44#include <assert.h> 44#include <assert.h>
45#include <errno.h> 45#include <errno.h>
46#include <sys/types.h> 46#include <sys/types.h>
47#ifndef WIN32
47#include <sys/wait.h> 48# include <sys/wait.h>
49#endif
48#include <sys/time.h> 50#include <sys/time.h>
49#include <time.h> 51#include <time.h>
50 52
51/**/ 53/**/
52 54
62# define EV_USE_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 */
63#endif 65#endif
64 66
65#ifndef EV_USE_EPOLL 67#ifndef EV_USE_EPOLL
66# define EV_USE_EPOLL 0 68# define EV_USE_EPOLL 0
69#endif
70
71#ifndef EV_USE_KQUEUE
72# define EV_USE_KQUEUE 0
67#endif 73#endif
68 74
69#ifndef EV_USE_REALTIME 75#ifndef EV_USE_REALTIME
70# define EV_USE_REALTIME 1 76# define EV_USE_REALTIME 1
71#endif 77#endif
434} 440}
435 441
436static void 442static void
437siginit (void) 443siginit (void)
438{ 444{
445#ifndef WIN32
439 fcntl (sigpipe [0], F_SETFD, FD_CLOEXEC); 446 fcntl (sigpipe [0], F_SETFD, FD_CLOEXEC);
440 fcntl (sigpipe [1], F_SETFD, FD_CLOEXEC); 447 fcntl (sigpipe [1], F_SETFD, FD_CLOEXEC);
441 448
442 /* rather than sort out wether we really need nb, set it */ 449 /* rather than sort out wether we really need nb, set it */
443 fcntl (sigpipe [0], F_SETFL, O_NONBLOCK); 450 fcntl (sigpipe [0], F_SETFL, O_NONBLOCK);
444 fcntl (sigpipe [1], F_SETFL, O_NONBLOCK); 451 fcntl (sigpipe [1], F_SETFL, O_NONBLOCK);
452#endif
445 453
446 ev_io_set (&sigev, sigpipe [0], EV_READ); 454 ev_io_set (&sigev, sigpipe [0], EV_READ);
447 ev_io_start (&sigev); 455 ev_io_start (&sigev);
448} 456}
449 457
460 468
461/*****************************************************************************/ 469/*****************************************************************************/
462 470
463static struct ev_child *childs [PID_HASHSIZE]; 471static struct ev_child *childs [PID_HASHSIZE];
464static struct ev_signal childev; 472static struct ev_signal childev;
473
474#ifndef WIN32
465 475
466#ifndef WCONTINUED 476#ifndef WCONTINUED
467# define WCONTINUED 0 477# define WCONTINUED 0
468#endif 478#endif
469 479
480 w->status = status; 490 w->status = status;
481 event ((W)w, EV_CHILD); 491 event ((W)w, EV_CHILD);
482 } 492 }
483} 493}
484 494
485/*****************************************************************************/ 495#endif
486 496
497/*****************************************************************************/
498
499#if EV_USE_KQUEUE
500# include "ev_kqueue.c"
501#endif
487#if EV_USE_EPOLL 502#if EV_USE_EPOLL
488# include "ev_epoll.c" 503# include "ev_epoll.c"
489#endif 504#endif
490#if EV_USE_POLL 505#if EV_USE_POLL
491# include "ev_poll.c" 506# include "ev_poll.c"
539 methods = atoi (getenv ("LIBEV_METHODS")); 554 methods = atoi (getenv ("LIBEV_METHODS"));
540 else 555 else
541 methods = EVMETHOD_ANY; 556 methods = EVMETHOD_ANY;
542 557
543 ev_method = 0; 558 ev_method = 0;
559#if EV_USE_KQUEUE
560 if (!ev_method && (methods & EVMETHOD_KQUEUE)) kqueue_init (methods);
561#endif
544#if EV_USE_EPOLL 562#if EV_USE_EPOLL
545 if (!ev_method && (methods & EVMETHOD_EPOLL )) epoll_init (methods); 563 if (!ev_method && (methods & EVMETHOD_EPOLL )) epoll_init (methods);
546#endif 564#endif
547#if EV_USE_POLL 565#if EV_USE_POLL
548 if (!ev_method && (methods & EVMETHOD_POLL )) poll_init (methods); 566 if (!ev_method && (methods & EVMETHOD_POLL )) poll_init (methods);
554 if (ev_method) 572 if (ev_method)
555 { 573 {
556 ev_watcher_init (&sigev, sigcb); 574 ev_watcher_init (&sigev, sigcb);
557 siginit (); 575 siginit ();
558 576
577#ifndef WIN32
559 ev_signal_init (&childev, childcb, SIGCHLD); 578 ev_signal_init (&childev, childcb, SIGCHLD);
560 ev_signal_start (&childev); 579 ev_signal_start (&childev);
580#endif
561 } 581 }
562 } 582 }
563 583
564 return ev_method; 584 return ev_method;
565} 585}
858} 878}
859 879
860static void 880static void
861ev_start (W w, int active) 881ev_start (W w, int active)
862{ 882{
883 if (w->priority < EV_MINPRI) w->priority = EV_MINPRI;
884 if (w->priority > EV_MAXPRI) w->priority = EV_MAXPRI;
885
863 w->active = active; 886 w->active = active;
864} 887}
865 888
866static void 889static void
867ev_stop (W w) 890ev_stop (W w)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines