]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] changed fd_set*/fd_clr* functions to return ints
authorWilly Tarreau <w@1wt.eu>
Sun, 8 Apr 2007 22:54:46 +0000 (00:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 8 Apr 2007 22:54:46 +0000 (00:54 +0200)
The fd_* functions now return ints so that they can be
factored when appropriate.

include/types/fd.h
src/ev_epoll.c
src/ev_poll.c
src/ev_select.c

index 6d8b31fb7117ac4bd4df5a95dc4ac41bd9bdc4c7..2128cb9b222b51cb71a9ecdc5d0ef3cf5637d900 100644 (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 */
index 65b3d74055a544d4f40e9646488787841d6d19be..56049bc046777117c03a71f0d85a4447a7e26535 100644 (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]);
index d43fa0c6cfd0aa7560b5b8752df70e01f37037cb..542742a0c10e710f74acfe163eafeb10553c0ff1 100644 (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]);
index 1ab7119bf62ab65ba96522a39fb341d459f6ec62..d019c214791d11c72794039a54785253990a351a 100644 (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]);