Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753049Ab2EWRLb (ORCPT ); Wed, 23 May 2012 13:11:31 -0400 Received: from mail.skyhub.de ([78.46.96.112]:41493 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752451Ab2EWRL3 (ORCPT ); Wed, 23 May 2012 13:11:29 -0400 Date: Wed, 23 May 2012 19:11:25 +0200 From: Borislav Petkov To: Linus Torvalds Cc: "H. Peter Anvin" , Peter Zijlstra , Borislav Petkov , mingo@kernel.org, linux-kernel@vger.kernel.org, frank.arnold@amd.com, akpm@linux-foundation.org, tglx@linutronix.de, linux-tip-commits@vger.kernel.org Subject: Re: [tip:x86/mce] x86/bitops: Move BIT_64() for a wider use Message-ID: <20120523171125.GD18284@liondog.tnic> Mail-Followup-To: Borislav Petkov , Linus Torvalds , "H. Peter Anvin" , Peter Zijlstra , Borislav Petkov , mingo@kernel.org, linux-kernel@vger.kernel.org, frank.arnold@amd.com, akpm@linux-foundation.org, tglx@linutronix.de, linux-tip-commits@vger.kernel.org References: <1337684026-19740-1-git-send-email-bp@amd64.org> <1337789429.9783.16.camel@laptop> <4FBD0C47.70600@zytor.com> <20120523161932.GN14757@aftab.osrc.amd.com> <1337790571.9783.28.camel@laptop> <4FBD10D5.6080602@zytor.com> <20120523165303.GB18284@liondog.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1345 Lines: 43 On Wed, May 23, 2012 at 09:57:47AM -0700, Linus Torvalds wrote: > On Wed, May 23, 2012 at 9:53 AM, Borislav Petkov 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/