[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.
This commit is contained in:
Willy Tarreau 2008-07-15 00:36:31 +02:00
parent ec6c5df018
commit 177e2b0127
4 changed files with 9 additions and 18 deletions

View File

@ -37,11 +37,9 @@
#include <common/config.h>
#include <common/standard.h>
/* 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

View File

@ -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<<INTBITS) && fd < maxfd; count++, fd++) {
for (count = 0, fd = fds * BITS_PER_INT; count < BITS_PER_INT && fd < maxfd; count++, fd++) {
#define FDSETS_ARE_INT_ALIGNED
#ifdef FDSETS_ARE_INT_ALIGNED
@ -107,8 +107,8 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
sr = (rn >> count) & 1;
sw = (wn >> count) & 1;
#else
sr = FD_ISSET(fd&((1<<INTBITS)-1), (typeof(fd_set*))&rn);
sw = FD_ISSET(fd&((1<<INTBITS)-1), (typeof(fd_set*))&wn);
sr = FD_ISSET(fd&(BITS_PER_INT-1), (typeof(fd_set*))&rn);
sw = FD_ISSET(fd&(BITS_PER_INT-1), (typeof(fd_set*))&wn);
#endif
#else
sr = FD_ISSET(fd, fd_evts[DIR_RD]);

View File

@ -135,11 +135,11 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
if (status <= 0)
return;
for (fds = 0; (fds << INTBITS) < maxfd; fds++) {
for (fds = 0; (fds * BITS_PER_INT) < maxfd; fds++) {
if ((((int *)(tmp_evts[DIR_RD]))[fds] | ((int *)(tmp_evts[DIR_WR]))[fds]) == 0)
continue;
for (count = 1<<INTBITS, fd = fds << INTBITS; count && fd < maxfd; count--, fd++) {
for (count = BITS_PER_INT, fd = fds * BITS_PER_INT; count && fd < maxfd; count--, fd++) {
/* if we specify read first, the accepts and zero reads will be
* seen first. Moreover, system buffers will be flushed faster.
*/

View File

@ -395,13 +395,6 @@ void init(int argc, char **argv)
char *tmp;
char *cfg_pidfile = NULL;
if (1<<INTBITS != sizeof(int)*8) {
fprintf(stderr,
"Error: wrong architecture. Recompile so that sizeof(int)=%d\n",
(int)(sizeof(int)*8));
exit(1);
}
/*
* Initialize the previously static variables.
*/