[MINOR] changed fd_set*/fd_clr* functions to return ints

The fd_* functions now return ints so that they can be
factored when appropriate.
This commit is contained in:
Willy Tarreau 2007-04-09 00:54:46 +02:00
parent 28d86862bc
commit 97129b5408
4 changed files with 31 additions and 23 deletions

View File

@ -63,19 +63,21 @@ struct fdtab {
* 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 */

View File

@ -47,22 +47,24 @@ static int epoll_fd;
* 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 @@ REGPRM2 static int __fd_cond_s(const int fd, const int dir)
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]);

View File

@ -37,22 +37,24 @@ static struct pollfd *poll_events = NULL;
* 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 @@ REGPRM2 static int __fd_cond_s(const int fd, const int dir)
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]);

View File

@ -35,22 +35,24 @@ static fd_set *tmp_evts[2];
* 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 @@ REGPRM2 static int __fd_cond_s(const int fd, const int dir)
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 @@ REGPRM2 static int __fd_cond_c(const int fd, const int dir)
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]);