From: Willy Tarreau Date: Mon, 14 Jul 2008 22:36:31 +0000 (+0200) Subject: [CLEANUP] remove dependency on obsolete INTBITS macro X-Git-Tag: v1.3.16-rc1~229 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=177e2b012723ef65c6c7f850df3e6e0cd2cca2b4;p=thirdparty%2Fhaproxy.git [CLEANUP] remove dependency on obsolete INTBITS macro The INTBITS macro was found to be already defined on some platforms, and to equal 32 (while INTBITS was 5 here). Due to pure luck, there was no declaration conflict, but it's nonetheless a problem to fix. Looking at the code showed that this macro was only used for left shifts and nothing else anymore. So the replacement is obvious. The new macro, BITS_PER_INT is more obviously correct. --- diff --git a/include/common/compat.h b/include/common/compat.h index 4e86325e69..8d406e5c46 100644 --- a/include/common/compat.h +++ b/include/common/compat.h @@ -37,11 +37,9 @@ #include #include -/* INTBITS - * how many bits are needed to code the size of an int on the target platform. - * (eg: 32bits -> 5) - */ -#define INTBITS 5 +#ifndef BITS_PER_INT +#define BITS_PER_INT (8*sizeof(int)) +#endif /* this is for libc5 for example */ #ifndef TCP_NODELAY diff --git a/src/ev_poll.c b/src/ev_poll.c index 5f0a2c49b9..4a1eb8bf93 100644 --- a/src/ev_poll.c +++ b/src/ev_poll.c @@ -92,13 +92,13 @@ REGPRM2 static void _do_poll(struct poller *p, int exp) unsigned rn, wn; /* read new, write new */ nbfd = 0; - for (fds = 0; (fds << INTBITS) < maxfd; fds++) { + for (fds = 0; (fds * BITS_PER_INT) < maxfd; fds++) { rn = ((int*)fd_evts[DIR_RD])[fds]; wn = ((int*)fd_evts[DIR_WR])[fds]; if ((rn|wn)) { - for (count = 0, fd = fds << INTBITS; count < (1<> count) & 1; sw = (wn >> count) & 1; #else - sr = FD_ISSET(fd&((1<