… | |
… | |
115 | # else |
115 | # else |
116 | # undef EV_USE_EPOLL |
116 | # undef EV_USE_EPOLL |
117 | # define EV_USE_EPOLL 0 |
117 | # define EV_USE_EPOLL 0 |
118 | # endif |
118 | # endif |
119 | |
119 | |
|
|
120 | # if HAVE_LINUX_AIO_ABI_H |
|
|
121 | # ifndef EV_USE_LINUXAIO |
|
|
122 | # define EV_USE_LINUXAIO EV_FEATURE_BACKENDS |
|
|
123 | # endif |
|
|
124 | # else |
|
|
125 | # undef EV_USE_LINUXAIO |
|
|
126 | # define EV_USE_LINUXAIO 0 |
|
|
127 | # endif |
|
|
128 | |
120 | # if HAVE_KQUEUE && HAVE_SYS_EVENT_H |
129 | # if HAVE_KQUEUE && HAVE_SYS_EVENT_H |
121 | # ifndef EV_USE_KQUEUE |
130 | # ifndef EV_USE_KQUEUE |
122 | # define EV_USE_KQUEUE EV_FEATURE_BACKENDS |
131 | # define EV_USE_KQUEUE EV_FEATURE_BACKENDS |
123 | # endif |
132 | # endif |
124 | # else |
133 | # else |
… | |
… | |
316 | #ifndef EV_USE_PORT |
325 | #ifndef EV_USE_PORT |
317 | # define EV_USE_PORT 0 |
326 | # define EV_USE_PORT 0 |
318 | #endif |
327 | #endif |
319 | |
328 | |
320 | #ifndef EV_USE_LINUXAIO |
329 | #ifndef EV_USE_LINUXAIO |
|
|
330 | # if __linux /* libev currently assumes linux/aio_abi.h is always available on linux */ |
|
|
331 | # define EV_USE_LINUXAIO 1 |
|
|
332 | # else |
321 | # define EV_USE_LINUXAIO 0 |
333 | # define EV_USE_LINUXAIO 0 |
|
|
334 | # endif |
322 | #endif |
335 | #endif |
323 | |
336 | |
324 | #ifndef EV_USE_INOTIFY |
337 | #ifndef EV_USE_INOTIFY |
325 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) |
338 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) |
326 | # define EV_USE_INOTIFY EV_FEATURE_OS |
339 | # define EV_USE_INOTIFY EV_FEATURE_OS |
… | |
… | |
383 | /* aix's poll.h seems to cause lots of trouble */ |
396 | /* aix's poll.h seems to cause lots of trouble */ |
384 | #ifdef _AIX |
397 | #ifdef _AIX |
385 | /* AIX has a completely broken poll.h header */ |
398 | /* AIX has a completely broken poll.h header */ |
386 | # undef EV_USE_POLL |
399 | # undef EV_USE_POLL |
387 | # define EV_USE_POLL 0 |
400 | # define EV_USE_POLL 0 |
388 | #endif |
|
|
389 | |
|
|
390 | #if EV_USE_LINUXAIO |
|
|
391 | # include <linux/aio_abi.h> /* probably only needed for aio_context_t */ |
|
|
392 | #endif |
401 | #endif |
393 | |
402 | |
394 | /* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */ |
403 | /* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */ |
395 | /* which makes programs even slower. might work on other unices, too. */ |
404 | /* which makes programs even slower. might work on other unices, too. */ |
396 | #if EV_USE_CLOCK_SYSCALL |
405 | #if EV_USE_CLOCK_SYSCALL |
… | |
… | |
424 | |
433 | |
425 | #if !EV_USE_NANOSLEEP |
434 | #if !EV_USE_NANOSLEEP |
426 | /* hp-ux has it in sys/time.h, which we unconditionally include above */ |
435 | /* hp-ux has it in sys/time.h, which we unconditionally include above */ |
427 | # if !defined _WIN32 && !defined __hpux |
436 | # if !defined _WIN32 && !defined __hpux |
428 | # include <sys/select.h> |
437 | # include <sys/select.h> |
|
|
438 | # endif |
|
|
439 | #endif |
|
|
440 | |
|
|
441 | #if EV_USE_LINUXAIO |
|
|
442 | # include <sys/syscall.h> |
|
|
443 | # if !SYS_io_getevents || !EV_USE_EPOLL /* ev_linxaio uses ev_poll.c:ev_epoll_create */ |
|
|
444 | # undef EV_USE_LINUXAIO |
|
|
445 | # define EV_USE_LINUXAIO 0 |
429 | # endif |
446 | # endif |
430 | #endif |
447 | #endif |
431 | |
448 | |
432 | #if EV_USE_INOTIFY |
449 | #if EV_USE_INOTIFY |
433 | # include <sys/statfs.h> |
450 | # include <sys/statfs.h> |
… | |
… | |
1586 | # include "ev_win32.c" |
1603 | # include "ev_win32.c" |
1587 | #endif |
1604 | #endif |
1588 | |
1605 | |
1589 | /*****************************************************************************/ |
1606 | /*****************************************************************************/ |
1590 | |
1607 | |
|
|
1608 | #if EV_USE_LINUXAIO |
|
|
1609 | # include <linux/aio_abi.h> /* probably only needed for aio_context_t */ |
|
|
1610 | #endif |
|
|
1611 | |
1591 | /* define a suitable floor function (only used by periodics atm) */ |
1612 | /* define a suitable floor function (only used by periodics atm) */ |
1592 | |
1613 | |
1593 | #if EV_USE_FLOOR |
1614 | #if EV_USE_FLOOR |
1594 | # include <math.h> |
1615 | # include <math.h> |
1595 | # define ev_floor(v) floor (v) |
1616 | # define ev_floor(v) floor (v) |
… | |
… | |
1968 | { |
1989 | { |
1969 | *cur = array_nextsize (elem, *cur, cnt); |
1990 | *cur = array_nextsize (elem, *cur, cnt); |
1970 | return ev_realloc (base, elem * *cur); |
1991 | return ev_realloc (base, elem * *cur); |
1971 | } |
1992 | } |
1972 | |
1993 | |
1973 | #define array_needsize_noinit(base,count) |
1994 | #define array_needsize_noinit(base,offset,count) |
1974 | |
1995 | |
1975 | #define array_needsize_zerofill(base,count) \ |
1996 | #define array_needsize_zerofill(base,offset,count) \ |
1976 | memset ((void *)(base), 0, sizeof (*(base)) * (count)) |
1997 | memset ((void *)(base + offset), 0, sizeof (*(base)) * (count)) |
1977 | |
1998 | |
1978 | #define array_needsize(type,base,cur,cnt,init) \ |
1999 | #define array_needsize(type,base,cur,cnt,init) \ |
1979 | if (expect_false ((cnt) > (cur))) \ |
2000 | if (expect_false ((cnt) > (cur))) \ |
1980 | { \ |
2001 | { \ |
1981 | ecb_unused int ocur_ = (cur); \ |
2002 | ecb_unused int ocur_ = (cur); \ |
1982 | (base) = (type *)array_realloc \ |
2003 | (base) = (type *)array_realloc \ |
1983 | (sizeof (type), (base), &(cur), (cnt)); \ |
2004 | (sizeof (type), (base), &(cur), (cnt)); \ |
1984 | init ((base) + (ocur_), (cur) - ocur_); \ |
2005 | init ((base), ocur_, ((cur) - ocur_)); \ |
1985 | } |
2006 | } |
1986 | |
2007 | |
1987 | #if 0 |
2008 | #if 0 |
1988 | #define array_slim(type,stem) \ |
2009 | #define array_slim(type,stem) \ |
1989 | if (stem ## max < array_roundsize (stem ## cnt >> 2)) \ |
2010 | if (stem ## max < array_roundsize (stem ## cnt >> 2)) \ |
… | |
… | |
2712 | # include "ev_port.c" |
2733 | # include "ev_port.c" |
2713 | #endif |
2734 | #endif |
2714 | #if EV_USE_KQUEUE |
2735 | #if EV_USE_KQUEUE |
2715 | # include "ev_kqueue.c" |
2736 | # include "ev_kqueue.c" |
2716 | #endif |
2737 | #endif |
|
|
2738 | #if EV_USE_EPOLL |
|
|
2739 | # include "ev_epoll.c" |
|
|
2740 | #endif |
2717 | #if EV_USE_LINUXAIO |
2741 | #if EV_USE_LINUXAIO |
2718 | # include "ev_linuxaio.c" |
2742 | # include "ev_linuxaio.c" |
2719 | #endif |
|
|
2720 | #if EV_USE_EPOLL |
|
|
2721 | # include "ev_epoll.c" |
|
|
2722 | #endif |
2743 | #endif |
2723 | #if EV_USE_POLL |
2744 | #if EV_USE_POLL |
2724 | # include "ev_poll.c" |
2745 | # include "ev_poll.c" |
2725 | #endif |
2746 | #endif |
2726 | #if EV_USE_SELECT |
2747 | #if EV_USE_SELECT |
… | |
… | |
2783 | flags &= ~EVBACKEND_KQUEUE; /* horribly broken, even for sockets */ |
2804 | flags &= ~EVBACKEND_KQUEUE; /* horribly broken, even for sockets */ |
2784 | flags &= ~EVBACKEND_POLL; /* poll is based on kqueue from 10.5 onwards */ |
2805 | flags &= ~EVBACKEND_POLL; /* poll is based on kqueue from 10.5 onwards */ |
2785 | #endif |
2806 | #endif |
2786 | #ifdef __FreeBSD__ |
2807 | #ifdef __FreeBSD__ |
2787 | flags &= ~EVBACKEND_POLL; /* poll return value is unusable (http://forums.freebsd.org/archive/index.php/t-10270.html) */ |
2808 | flags &= ~EVBACKEND_POLL; /* poll return value is unusable (http://forums.freebsd.org/archive/index.php/t-10270.html) */ |
|
|
2809 | #endif |
|
|
2810 | |
|
|
2811 | /* TODO: linuxaio is very experimental */ |
|
|
2812 | #if !EV_RECOMMEND_LINUXAIO |
|
|
2813 | flags &= ~EVBACKEND_LINUXAIO; |
2788 | #endif |
2814 | #endif |
2789 | |
2815 | |
2790 | return flags; |
2816 | return flags; |
2791 | } |
2817 | } |
2792 | |
2818 | |