From: Willy Tarreau Date: Sun, 8 Apr 2007 22:54:46 +0000 (+0200) Subject: [MINOR] changed fd_set*/fd_clr* functions to return ints X-Git-Tag: v1.3.9~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=97129b5408cd5e8a50479b8ced522660eed3559c;p=thirdparty%2Fhaproxy.git [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 6d8b31fb71..2128cb9b22 100644 --- a/include/types/fd.h +++ b/include/types/fd.h @@ -63,19 +63,21 @@ struct fdtab { * poller should set it to 100. * - 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 is being polled for dir */ - REGPRM2 void (*set)(const int fd, const int dir); /* set polling on for */ - REGPRM2 void (*clr)(const int fd, const int dir); /* clear polling on for */ - REGPRM2 int (*cond_s)(const int fd, const int dir); /* set polling on for if unset */ - REGPRM2 int (*cond_c)(const int fd, const int dir); /* clear polling on for if set */ + REGPRM2 int (*isset)(const int fd, int dir); /* check if is being polled for dir */ + REGPRM2 int (*set)(const int fd, int dir); /* set polling on for */ + REGPRM2 int (*clr)(const int fd, int dir); /* clear polling on for */ + REGPRM2 int (*cond_s)(const int fd, int dir); /* set polling on for if unset */ + REGPRM2 int (*cond_c)(const int fd, int dir); /* clear polling on for if set */ REGPRM1 void (*rem)(const int fd); /* remove any polling on */ REGPRM1 void (*clo)(const int fd); /* mark 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 65b3d74055..56049bc046 100644 --- a/src/ev_epoll.c +++ b/src/ev_epoll.c @@ -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]); diff --git a/src/ev_poll.c b/src/ev_poll.c index d43fa0c6cf..542742a0c1 100644 --- a/src/ev_poll.c +++ b/src/ev_poll.c @@ -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]); diff --git a/src/ev_select.c b/src/ev_select.c index 1ab7119bf6..d019c21479 100644 --- a/src/ev_select.c +++ b/src/ev_select.c @@ -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]);