mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh Boyer <jwboyer@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jeff Law <law@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] posix_types.h: make __NFDBITS compatible with glibc definition
Date: Tue, 24 Jul 2012 16:10:45 -0400	[thread overview]
Message-ID: <20120724201045.GH10534@zod.bos.redhat.com> (raw)
In-Reply-To: <CA+55aFygfHj3-PLPj2RZ6pg==7sf3=zKDATW3rVaE9jSOxCd_g@mail.gmail.com>

On Tue, Jul 24, 2012 at 12:55:38PM -0700, Linus Torvalds wrote:
> On Tue, Jul 24, 2012 at 12:43 PM, Josh Boyer <jwboyer@redhat.com> wrote:
> >+  ({ long int __d = (d);                                                   \
> >      (__builtin_constant_p (__d)                                           \
> >-      ? (__d >= __FD_SETSIZE                                               \
> >-        ? __fdelt_warn (__d) : (__d / __NFDBITS))                          \
> >+      ? (0 <= __d && __d < __FD_SETSIZE                                            \
> >+        ? (__d / __NFDBITS)                                                \
> >+        : __fdelt_warn (__d))                                              \
> >       : __fdelt_chk (__d)); })
> 
> Ugh. This depends intimately on gcc doing the whole value range
> propagation thing, and probably generates horrible code when not
> optimizing, but whatever. It's irrelevant.
> 
> I vote we get rid of the crap. We'll force-redefine __FD_SETSIZE,
> because that's the one we really care about. And then just use our
> internal names for anything else.

Your vote counts more than mine ;).  I just want the problem solved in a
reasonable fasion since it's causing build failures now and the bug was
stalled.
 
> IOW, just something like this (whitespace-damaged on purpose, because
> it won't even compile as-is: we'll also need to replace the few uses
> of __NFDBITS in the kernel with BITS_PER_LONG).
> 
>    diff --git a/include/linux/posix_types.h b/include/linux/posix_types.h
>   index f04c98cf44f3..8a79a5021dc1 100644
>   --- a/include/linux/posix_types.h
>   +++ b/include/linux/posix_types.h
>   @@ -15,26 +15,14 @@
>     */
> 
>    /*
>   - * Those macros may have been defined in <gnu/types.h>. But we always
>   - * use the ones here.
>   + * This macro may have been defined in <gnu/types.h>. But we always
>   + * use the one here.
>     */
>   -#undef __NFDBITS
>   -#define __NFDBITS	(8 * sizeof(unsigned long))
>   -
>    #undef __FD_SETSIZE
>    #define __FD_SETSIZE	1024
> 
>   -#undef __FDSET_LONGS
>   -#define __FDSET_LONGS	(__FD_SETSIZE/__NFDBITS)
>   -
>   -#undef __FDELT
>   -#define	__FDELT(d)	((d) / __NFDBITS)
>   -
>   -#undef __FDMASK
>   -#define	__FDMASK(d)	(1UL << ((d) % __NFDBITS))
>   -
>    typedef struct {
>   -	unsigned long fds_bits [__FDSET_LONGS];
>   +	unsigned long fds_bits [__FD_SETSIZE / (8*sizeof(long))];
>    } __kernel_fd_set;
> 
>    /* Type of a signal handler.  */
> 
> Hmm?

Seems fine to me.  In addition to the s/__NFDBITS/BITS_PER_LONG change,
I'm guessing you'll want the odd FD_ISSET/CLR/ZERO/etc macros in
linux/time.h killed as well?

If you don't get to it before me, I'll try whipping something up either
later this evening or first thing in the morning.

josh

  reply	other threads:[~2012-07-24 20:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-24 18:12 [PATCH] posix_types.h: make __NFDBITS match " Josh Boyer
2012-07-24 18:20 ` Linus Torvalds
2012-07-24 18:24   ` Josh Boyer
2012-07-24 18:32     ` [PATCH v2] posix_types.h: make __NFDBITS compatible with " Josh Boyer
2012-07-24 18:46       ` Linus Torvalds
2012-07-24 19:03         ` Josh Boyer
2012-07-24 19:09           ` Linus Torvalds
2012-07-24 19:15             ` Jeff Law
2012-07-24 19:24               ` Linus Torvalds
2012-07-24 19:26                 ` Jeff Law
2012-07-24 19:43                   ` Josh Boyer
2012-07-24 19:55                     ` Linus Torvalds
2012-07-24 20:10                       ` Josh Boyer [this message]
2012-07-24 20:13                         ` Linus Torvalds
2012-07-24 20:02                     ` Andreas Schwab
2012-07-24 19:43                   ` Linus Torvalds
2012-07-24 20:01                     ` Jeff Law
2012-07-24 19:19     ` [PATCH] posix_types.h: make __NFDBITS match " Jeff Law
2012-07-24 19:37       ` Linus Torvalds
2012-07-24 19:39         ` Linus Torvalds
2012-07-24 19:41         ` Josh Boyer
2012-07-24 19:59           ` Linus Torvalds
2012-07-24 20:11             ` Linus Torvalds
2012-07-24 20:52               ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120724201045.GH10534@zod.bos.redhat.com \
    --to=jwboyer@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=law@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®