On Tue, Jul 24, 2012 at 12:43 PM, Josh Boyer <[email protected]> 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.

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?

              Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to