lkml.org 
[lkml]   [2004]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: fcntl error
Date

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/

\
 
 \ /
  Last update: 2005-03-22 14:01    [W:0.044 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site