lkml.org 
[lkml]   [2012]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] posix_types.h: make __NFDBITS compatible with glibc definition
On Tue, Jul 24, 2012 at 11:46:25AM -0700, Linus Torvalds wrote:
> On Tue, Jul 24, 2012 at 11:32 AM, Josh Boyer <jwboyer@redhat.com> wrote:
> > Recent glibc made a change to suppress sign-conversion warnings from FD_SET
> > (glibc commit ceb9e56b3d1). That patch solved the particular error it was
> > aiming to, however applications that #include <linux/types.h> after
> > including <sys/select.h> can now hit a build failure if -Werror=sign-compare
> > and -D_FORTIFY_SOURCE=2 is passed to gcc. This can be seen when building
> > this trivial application against a recent enough glibc:
>
> Looking more at this, I now hate it for *another* reason.
>
> Making __NFDBITS be a signed value turns __FDELT() and __FDMASK() into
> potentially pure and utter crap. Doing signed divisions (or modulus)
> is a disaster - suddenly it's not just a bit shift any more.
>
> Guys, the glibc people really seem to not have thought their change
> through. Or maybe they fixed their __FDELT/__FDMASK at the same time?

Jeff can probably answer this better than I can, so likely best to wait
for him.

FWIW, the definitions of __FD_ELT/__FD_MASK in glibc are:

#define __FD_ELT(d) ((d) / __NFDBITS)
#define __FD_MASK(d) ((__fd_mask) 1 << ((d) % __NFDBITS))

where __fd_mask is 'typdef long int'.

__NFDBITS was changed to int type with glibc commit eb0b6cb6e in 2009,
and __FDELT/__FDMASK were basically renamed with glibc commit
e529793b508 in 2011.

josh


\
 
 \ /
  Last update: 2012-07-24 21:41    [W:0.170 / U:0.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site