[MINOR] changed fd_set*/fd_clr* functions to return ints
The fd_* functions now return ints so that they can be
factored when appropriate.
diff --git a/include/types/fd.h b/include/types/fd.h
index 6d8b31f..2128cb9 100644
--- a/include/types/fd.h
+++ b/include/types/fd.h
@@ -63,19 +63,21 @@
* poller should set it to 100.
* - <private> is initialized by the poller's init() function, and cleaned by
* the term() function.
- * - cond_s() checks if fd was not set then sets it and returns 1. Otherwise 0.
- * - cond_c() checks if fd was set then clears it and returns 1. Otherwise 0.
+ * - cond_s() checks if fd was not set then sets it and returns 1. Otherwise
+ * it returns 0. It may be the same as set().
+ * - cond_c() checks if fd was set then clears it and returns 1. Otherwise
+ * it returns 0. It may be the same as clr().
* - clo() should be used to do indicate the poller that fd will be closed. It
* may be the same as rem() on some pollers.
* - poll() calls the poller, waiting at most wait_time ms.
*/
struct poller {
void *private; /* any private data for the poller */
- REGPRM2 int (*isset)(const int fd, const int dir); /* check if <fd> is being polled for dir <dir> */
- REGPRM2 void (*set)(const int fd, const int dir); /* set polling on <fd> for <dir> */
- REGPRM2 void (*clr)(const int fd, const int dir); /* clear polling on <fd> for <dir> */
- REGPRM2 int (*cond_s)(const int fd, const int dir); /* set polling on <fd> for <dir> if unset */
- REGPRM2 int (*cond_c)(const int fd, const int dir); /* clear polling on <fd> for <dir> if set */
+ REGPRM2 int (*isset)(const int fd, int dir); /* check if <fd> is being polled for dir <dir> */
+ REGPRM2 int (*set)(const int fd, int dir); /* set polling on <fd> for <dir> */
+ REGPRM2 int (*clr)(const int fd, int dir); /* clear polling on <fd> for <dir> */
+ REGPRM2 int (*cond_s)(const int fd, int dir); /* set polling on <fd> for <dir> if unset */
+ REGPRM2 int (*cond_c)(const int fd, int dir); /* clear polling on <fd> for <dir> if set */
REGPRM1 void (*rem)(const int fd); /* remove any polling on <fd> */
REGPRM1 void (*clo)(const int fd); /* mark <fd> as closed */
REGPRM2 void (*poll)(struct poller *p, int wait_time); /* the poller itself */
diff --git a/src/ev_epoll.c b/src/ev_epoll.c
index 65b3d74..56049bc 100644
--- a/src/ev_epoll.c
+++ b/src/ev_epoll.c
@@ -47,22 +47,24 @@
* instead of the usual macros improve the FD_* performance by about 80%,
* and that marking them regparm(2) adds another 20%.
*/
-REGPRM2 static int __fd_isset(const int fd, const int dir)
+REGPRM2 static int __fd_isset(const int fd, int dir)
{
return FD_ISSET(fd, fd_evts[dir]);
}
-REGPRM2 static void __fd_set(const int fd, const int dir)
+REGPRM2 static int __fd_set(const int fd, int dir)
{
FD_SET(fd, fd_evts[dir]);
+ return 0;
}
-REGPRM2 static void __fd_clr(const int fd, const int dir)
+REGPRM2 static int __fd_clr(const int fd, int dir)
{
FD_CLR(fd, fd_evts[dir]);
+ return 0;
}
-REGPRM2 static int __fd_cond_s(const int fd, const int dir)
+REGPRM2 static int __fd_cond_s(const int fd, int dir)
{
int ret;
ret = !FD_ISSET(fd, fd_evts[dir]);
@@ -71,7 +73,7 @@
return ret;
}
-REGPRM2 static int __fd_cond_c(const int fd, const int dir)
+REGPRM2 static int __fd_cond_c(const int fd, int dir)
{
int ret;
ret = FD_ISSET(fd, fd_evts[dir]);
diff --git a/src/ev_poll.c b/src/ev_poll.c
index d43fa0c..542742a 100644
--- a/src/ev_poll.c
+++ b/src/ev_poll.c
@@ -37,22 +37,24 @@
* instead of the usual macros improve the FD_* performance by about 80%,
* and that marking them regparm(2) adds another 20%.
*/
-REGPRM2 static int __fd_isset(const int fd, const int dir)
+REGPRM2 static int __fd_isset(const int fd, int dir)
{
return FD_ISSET(fd, fd_evts[dir]);
}
-REGPRM2 static void __fd_set(const int fd, const int dir)
+REGPRM2 static int __fd_set(const int fd, int dir)
{
FD_SET(fd, fd_evts[dir]);
+ return 0;
}
-REGPRM2 static void __fd_clr(const int fd, const int dir)
+REGPRM2 static int __fd_clr(const int fd, int dir)
{
FD_CLR(fd, fd_evts[dir]);
+ return 0;
}
-REGPRM2 static int __fd_cond_s(const int fd, const int dir)
+REGPRM2 static int __fd_cond_s(const int fd, int dir)
{
int ret;
ret = !FD_ISSET(fd, fd_evts[dir]);
@@ -61,7 +63,7 @@
return ret;
}
-REGPRM2 static int __fd_cond_c(const int fd, const int dir)
+REGPRM2 static int __fd_cond_c(const int fd, int dir)
{
int ret;
ret = FD_ISSET(fd, fd_evts[dir]);
diff --git a/src/ev_select.c b/src/ev_select.c
index 1ab7119..d019c21 100644
--- a/src/ev_select.c
+++ b/src/ev_select.c
@@ -35,22 +35,24 @@
* instead of the usual macros improve the FD_* performance by about 80%,
* and that marking them regparm(2) adds another 20%.
*/
-REGPRM2 static int __fd_isset(const int fd, const int dir)
+REGPRM2 static int __fd_isset(const int fd, int dir)
{
return FD_ISSET(fd, fd_evts[dir]);
}
-REGPRM2 static void __fd_set(const int fd, const int dir)
+REGPRM2 static int __fd_set(const int fd, int dir)
{
FD_SET(fd, fd_evts[dir]);
+ return 0;
}
-REGPRM2 static void __fd_clr(const int fd, const int dir)
+REGPRM2 static int __fd_clr(const int fd, int dir)
{
FD_CLR(fd, fd_evts[dir]);
+ return 0;
}
-REGPRM2 static int __fd_cond_s(const int fd, const int dir)
+REGPRM2 static int __fd_cond_s(const int fd, int dir)
{
int ret;
ret = !FD_ISSET(fd, fd_evts[dir]);
@@ -59,7 +61,7 @@
return ret;
}
-REGPRM2 static int __fd_cond_c(const int fd, const int dir)
+REGPRM2 static int __fd_cond_c(const int fd, int dir)
{
int ret;
ret = FD_ISSET(fd, fd_evts[dir]);
@@ -68,7 +70,7 @@
return ret;
}
-REGPRM1 static void __fd_rem(const int fd)
+REGPRM1 static void __fd_rem(int fd)
{
FD_CLR(fd, fd_evts[DIR_RD]);
FD_CLR(fd, fd_evts[DIR_WR]);