1 #ifndef INCLUDED_FDEVENT_IMPL_H
2 #define INCLUDED_FDEVENT_IMPL_H
5 /* select event-system */
7 #if defined(HAVE_EPOLL_CTL) && defined(HAVE_SYS_EPOLL_H)
8 # define FDEVENT_USE_LINUX_EPOLL
9 struct epoll_event
; /* declaration */
12 /* MacOS 10.3.x has poll.h under /usr/include/, all other unixes
13 * under /usr/include/sys/ */
14 #if defined HAVE_POLL && (defined(HAVE_SYS_POLL_H) || defined(HAVE_POLL_H))
15 # define FDEVENT_USE_POLL
16 struct pollfd
; /* declaration */
19 #if defined HAVE_SELECT
21 # include <winsock2.h>
23 # define FDEVENT_USE_SELECT
24 # ifdef HAVE_SYS_SELECT_H
25 # include <sys/select.h>
29 #if defined HAVE_SYS_DEVPOLL_H && defined(__sun)
30 # define FDEVENT_USE_SOLARIS_DEVPOLL
31 struct pollfd
; /* declaration */
34 #if defined HAVE_PORT_H && defined HAVE_PORT_CREATE && defined(__sun)
35 # define FDEVENT_USE_SOLARIS_PORT
39 #if defined HAVE_SYS_EVENT_H && defined HAVE_KQUEUE
40 # define FDEVENT_USE_FREEBSD_KQUEUE
41 struct kevent
; /* declaration */
44 #if defined HAVE_LIBEV
45 # define FDEVENT_USE_LIBEV
46 struct ev_loop
; /* declaration */
49 #include "base_decls.h"
50 #include "fdevent.h" /* (*fdevent_handler) */
53 FDEVENT_HANDLER_UNSET
,
54 FDEVENT_HANDLER_SELECT
,
56 FDEVENT_HANDLER_LINUX_SYSEPOLL
,
57 FDEVENT_HANDLER_SOLARIS_DEVPOLL
,
58 FDEVENT_HANDLER_SOLARIS_PORT
,
59 FDEVENT_HANDLER_FREEBSD_KQUEUE
,
64 * array of unused fd's
68 #ifdef FDEVENT_USE_POLL
81 int (*event_set
)(struct fdevents
*ev
, fdnode
*fdn
, int events
);
82 int (*event_del
)(struct fdevents
*ev
, fdnode
*fdn
);
83 int (*poll
)(struct fdevents
*ev
, int timeout_ms
);
87 #ifdef FDEVENT_USE_LINUX_EPOLL
89 struct epoll_event
*epoll_events
;
91 #ifdef FDEVENT_USE_SOLARIS_DEVPOLL
93 struct pollfd
*devpollfds
;
95 #ifdef FDEVENT_USE_SOLARIS_PORT
97 port_event_t
*port_events
;
99 #ifdef FDEVENT_USE_FREEBSD_KQUEUE
101 struct kevent
*kq_results
;
103 #ifdef FDEVENT_USE_LIBEV
104 struct ev_loop
*libev_loop
;
106 #ifdef FDEVENT_USE_POLL
107 struct pollfd
*pollfds
;
114 #ifdef FDEVENT_USE_SELECT
119 fd_set select_set_read
;
120 fd_set select_set_write
;
121 fd_set select_set_error
;
126 int (*reset
)(struct fdevents
*ev
);
127 void (*free
)(struct fdevents
*ev
);
128 fdevent_handler_t type
;
132 int fdevent_select_init(struct fdevents
*ev
);
134 int fdevent_poll_init(struct fdevents
*ev
);
136 int fdevent_linux_sysepoll_init(struct fdevents
*ev
);
138 int fdevent_solaris_devpoll_init(struct fdevents
*ev
);
140 int fdevent_solaris_port_init(struct fdevents
*ev
);
142 int fdevent_freebsd_kqueue_init(struct fdevents
*ev
);
144 int fdevent_libev_init(struct fdevents
*ev
);