#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
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
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]);
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.
*/
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.
*/