#endif
#define NETPOLL_MAXFDS 1024
-static net_pollfd_tabent_t fds[NETPOLL_MAXFDS] = {0};
+static net_pollfd_tabent_t fds[NETPOLL_MAXFDS] = {};
static int nfds = 0;
#if defined(NETPOLL_USE_SELECT)
return ev;
}
#elif defined(NETPOLL_USE_POLL)
-static struct pollfd pollfds[NETPOLL_MAXFDS] = {0};
+static struct pollfd pollfds[NETPOLL_MAXFDS] = {};
static int lastptr = 0;
void net_poll_init(void)
{
}
static void net_poll_reg_impl(int i, int ev)
{
- pollfds[i].events = (ev & NETPOLL_IN ? POLLIN : 0) | (ev & NETPOLL_OUT ? POLLOUT : 0);
+ pollfds[i].events = 0;
+ if (ev & NETPOLL_IN)
+ pollfds[i].events = POLLIN;
+ if (ev & NETPOLL_OUT)
+ pollfds[i].events = POLLOUT;
}
int net_poll_begin(void)
{
#elif defined(NETPOLL_USE_EPOLL)
#include <sys/epoll.h>
static int epollfd = -1;
-static struct epoll_event events[256] = {0};
+static struct epoll_event events[256] = {};
static int nevents = 0;
static int lastptr = 0;
-static struct net_pollfd fdsbuf[NETPOLL_MAXFDS] = {0};
+static struct net_pollfd fdsbuf[NETPOLL_MAXFDS] = {};
void net_poll_init(void)
{
for (int i = 0; i < NETPOLL_MAXFDS; i++)
}
static void net_poll_add_impl(int i)
{
- struct epoll_event e = { .data = { .ptr = fds[i] }};
+ struct epoll_event e = { .events = 0, .data = { .ptr = fds[i] }};
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fds[i]->fd, &e) == -1) {
perror("epoll_ctl(EPOLL_CTL_ADD)");
abort();
}
static void net_poll_reg_impl(int i, int ev)
{
- struct epoll_event e = { .data = { .ptr = fds[i] }};
- e.events = (ev & NETPOLL_IN ? EPOLLIN : 0) | (ev & NETPOLL_OUT ? EPOLLOUT : 0);
+ struct epoll_event e = { .events = 0, .data = { .ptr = fds[i] }};
+ if (ev & NETPOLL_IN)
+ e.events = EPOLLIN;
+ if (ev & NETPOLL_OUT)
+ e.events = EPOLLOUT;
if (epoll_ctl(epollfd, EPOLL_CTL_MOD, fds[i]->fd, &e) == -1) {
perror("epoll_ctl(EPOLL_CTL_MOD)");
abort();