[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120523171125.GD18284@liondog.tnic>
Date: Wed, 23 May 2012 19:11:25 +0200
From: Borislav Petkov <bp@...en8.de>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: "H. Peter Anvin" <hpa@...or.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Borislav Petkov <borislav.petkov@....com>, 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 09:57:47AM -0700, Linus Torvalds wrote:
> On Wed, May 23, 2012 at 9:53 AM, Borislav Petkov <bp@...en8.de> wrote:
> >
> > How about the following completely untested chunk:
>
> No, you can't do that. All standard C operations will return *one*
> type. That very much includes the ternary ?: operator.
And, in addition, hpa's example won't work too:
u64 msr = ~BIT(1);
> The *only* ways I know of to get two types are
>
> - C preprocessor stuff, ie
>
> #define BIT(x) __BIT_##x
>
> and then just enumerate all the 64 cases. This is portable, but it gets old.
Nah, that's ugly.
> - using __builtin_choose_expr(), which actually allows the two
> expressions to have different types, but requires a very strict
> compile-time constant (ie you cannot rely on the optimizer making it a
> constant - because it needs to choose the expression before the
> optimizer runs)
>
> There might be some other magic gcc extension, of course.
Hmm and if not, it looks like BIT_64 is the easiest and most readable
thing we can do.
Oh well.
--
Regards/Gruss,
Boris.
--
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