Messages in this thread | | | From | David Howells <> | Subject | Re: fcntl error | Date | Fri, 19 Mar 2004 09:38:52 +0000 |
| |
Linus Torvalds <torvalds@osdl.org> wrote: > That implies that while non-zero for "set" is ok, that non-zero had better > have the _low_ bits set. Which is not true on architectures that use just > a logical and with the bits in the word. > > Which implies that FD_ISSET() really must NOT be of that "logical and" > approach, which in turn implies that it should be either a inequality > expression, or it should be a "shift down and then and with 1".
Or maybe:
#define __FD_ISSET(d, set) (!!((set)->fds_bits[__FDELT(d)] & __FDMASK(d)))
Which is probably better than a shift and bit-and. That then leaves it up to the compiler as to whether the generation of 0 or 1 is actually necessary (which if isn't if it's just the condition in an if-statement).
Or even:
#define FD_ISSET(fd,fdsetp) (!!__FD_ISSET(fd,fdsetp))
Which would then apply to all arch's regardless.
David - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |