Clarify use of and need for mffs vs. ffs

Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
This commit is contained in:
Alan Coopersmith 2009-06-18 09:49:12 -07:00
parent 128cd03eec
commit 75c51c67b3
3 changed files with 6 additions and 4 deletions

View File

@ -92,6 +92,8 @@ SOFTWARE.
#define GetErrno() errno #define GetErrno() errno
#endif #endif
/* like ffs, but uses fd_mask instead of int as argument, so it works
when fd_mask is longer than an int, such as common 64-bit platforms */
/* modifications by raphael */ /* modifications by raphael */
int int
mffs(fd_mask mask) mffs(fd_mask mask)
@ -336,7 +338,7 @@ WaitForSomething(int *pClientsReady)
{ {
int client_priority, client_index; int client_priority, client_index;
curclient = ffs (clientsReadable.fds_bits[i]) - 1; curclient = mffs (clientsReadable.fds_bits[i]) - 1;
client_index = /* raphael: modified */ client_index = /* raphael: modified */
ConnectionTranslation[curclient + (i * (sizeof(fd_mask) * 8))]; ConnectionTranslation[curclient + (i * (sizeof(fd_mask) * 8))];
#else #else

View File

@ -827,7 +827,7 @@ EstablishNewConnections(ClientPtr clientUnused, pointer closure)
int status; int status;
#ifndef WIN32 #ifndef WIN32
curconn = ffs (readyconnections.fds_bits[i]) - 1; curconn = mffs (readyconnections.fds_bits[i]) - 1;
readyconnections.fds_bits[i] &= ~((fd_mask)1 << curconn); readyconnections.fds_bits[i] &= ~((fd_mask)1 << curconn);
curconn += (i * (sizeof(fd_mask)*8)); curconn += (i * (sizeof(fd_mask)*8));
#else #else
@ -992,7 +992,7 @@ CheckConnections(void)
mask = AllClients.fds_bits[i]; mask = AllClients.fds_bits[i];
while (mask) while (mask)
{ {
curoff = ffs (mask) - 1; curoff = mffs (mask) - 1;
curclient = curoff + (i * (sizeof(fd_mask)*8)); curclient = curoff + (i * (sizeof(fd_mask)*8));
FD_ZERO(&tmask); FD_ZERO(&tmask);
FD_SET(curclient, &tmask); FD_SET(curclient, &tmask);

View File

@ -204,7 +204,7 @@ extern Bool AnyClientsWriteBlocked;
extern WorkQueuePtr workQueue; extern WorkQueuePtr workQueue;
/* added by raphael */ /* in WaitFor.c */
#ifdef WIN32 #ifdef WIN32
typedef long int fd_mask; typedef long int fd_mask;
#endif #endif