lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 23 May 2012 09:40:40 -0700
From:	Linus Torvalds <torvalds@...ux-foundation.org>
To:	Borislav Petkov <borislav.petkov@....com>
Cc:	"H. Peter Anvin" <hpa@...or.com>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>, mingo@...nel.org,
	linux-kernel@...r.kernel.org, frank.arnold@....com,
	akpm@...ux-foundation.org, tglx@...utronix.de,
	linux-tip-commits@...r.kernel.org
Subject: Re: [tip:x86/mce] x86/bitops: Move BIT_64() for a wider use

On Wed, May 23, 2012 at 9:19 AM, Borislav Petkov
<borislav.petkov@....com> wrote:
>
> Actually we need a BIT() macro that works both
> on 32- and 64-bit. But that won't be that easy:

We could use __builtin_choose_expr(), but that *only* works with constants.

So we could do this:

  static inline unsigned long bit(unsigned int x)
  {
      return 1ul << x;
  }

  static inline u64 bit64(unsigned int x)
  {
      return 1ull << x;
  }

  #define BIT(x) \
    __builtin_choose_expr((x) < 8*sizeof(unsigned long), bit(x), bit64(x))

but then you *have* to use a plain constant for the BIT() macro.
Anything else will error out in a big way. Non-constant users would
have to be modified to use bit() and bit64() instead.

And no, I tested. You apparently can't do

  #define __is_longlongshift(x) \
        (__builtin_constant_p(x) && (x) < 8*(sizeof(long)))

because while that is a compile-time constant expression, it's not
"constant enough" for __builtin_choose_expr().

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ