From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S262125AbUCSJjL (ORCPT ); Fri, 19 Mar 2004 04:39:11 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S262104AbUCSJjL (ORCPT ); Fri, 19 Mar 2004 04:39:11 -0500 Received: from pub236.cambridge.redhat.com ([213.86.99.236]:20988 "EHLO warthog.cambridge.redhat.com") by vger.kernel.org with ESMTP id S262063AbUCSJjI (ORCPT ); Fri, 19 Mar 2004 04:39:08 -0500 From: David Howells In-Reply-To: References: <7051.1079628297@redhat.com> To: Linus Torvalds Cc: Andrew Morton , Kernel Mailing List , linux-arch@vger.kernel.org Subject: Re: fcntl error User-Agent: EMH/1.14.1 SEMI/1.14.4 (Hosorogi) FLIM/1.14.5 (Demachiyanagi) APEL/10.6 Emacs/21.3 (i386-redhat-linux-gnu) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.4 - "Hosorogi") Content-Type: text/plain; charset=US-ASCII Date: Fri, 19 Mar 2004 09:38:52 +0000 Message-ID: <9592.1079689132@redhat.com> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Linus Torvalds 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