mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-29 06:40:59 +01:00
[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:
parent
ec6c5df018
commit
177e2b0127
@ -37,11 +37,9 @@
|
|||||||
#include <common/config.h>
|
#include <common/config.h>
|
||||||
#include <common/standard.h>
|
#include <common/standard.h>
|
||||||
|
|
||||||
/* INTBITS
|
#ifndef BITS_PER_INT
|
||||||
* how many bits are needed to code the size of an int on the target platform.
|
#define BITS_PER_INT (8*sizeof(int))
|
||||||
* (eg: 32bits -> 5)
|
#endif
|
||||||
*/
|
|
||||||
#define INTBITS 5
|
|
||||||
|
|
||||||
/* this is for libc5 for example */
|
/* this is for libc5 for example */
|
||||||
#ifndef TCP_NODELAY
|
#ifndef TCP_NODELAY
|
||||||
|
|||||||
@ -92,13 +92,13 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
|||||||
unsigned rn, wn; /* read new, write new */
|
unsigned rn, wn; /* read new, write new */
|
||||||
|
|
||||||
nbfd = 0;
|
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];
|
rn = ((int*)fd_evts[DIR_RD])[fds];
|
||||||
wn = ((int*)fd_evts[DIR_WR])[fds];
|
wn = ((int*)fd_evts[DIR_WR])[fds];
|
||||||
|
|
||||||
if ((rn|wn)) {
|
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
|
#define FDSETS_ARE_INT_ALIGNED
|
||||||
#ifdef 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;
|
sr = (rn >> count) & 1;
|
||||||
sw = (wn >> count) & 1;
|
sw = (wn >> count) & 1;
|
||||||
#else
|
#else
|
||||||
sr = FD_ISSET(fd&((1<<INTBITS)-1), (typeof(fd_set*))&rn);
|
sr = FD_ISSET(fd&(BITS_PER_INT-1), (typeof(fd_set*))&rn);
|
||||||
sw = FD_ISSET(fd&((1<<INTBITS)-1), (typeof(fd_set*))&wn);
|
sw = FD_ISSET(fd&(BITS_PER_INT-1), (typeof(fd_set*))&wn);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
sr = FD_ISSET(fd, fd_evts[DIR_RD]);
|
sr = FD_ISSET(fd, fd_evts[DIR_RD]);
|
||||||
|
|||||||
@ -135,11 +135,11 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
|||||||
if (status <= 0)
|
if (status <= 0)
|
||||||
return;
|
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)
|
if ((((int *)(tmp_evts[DIR_RD]))[fds] | ((int *)(tmp_evts[DIR_WR]))[fds]) == 0)
|
||||||
continue;
|
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
|
/* if we specify read first, the accepts and zero reads will be
|
||||||
* seen first. Moreover, system buffers will be flushed faster.
|
* seen first. Moreover, system buffers will be flushed faster.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -395,13 +395,6 @@ void init(int argc, char **argv)
|
|||||||
char *tmp;
|
char *tmp;
|
||||||
char *cfg_pidfile = NULL;
|
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.
|
* Initialize the previously static variables.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user