From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752172Ab0HVT1P (ORCPT ); Sun, 22 Aug 2010 15:27:15 -0400 Received: from one.firstfloor.org ([213.235.205.2]:45589 "EHLO one.firstfloor.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750996Ab0HVT1N (ORCPT ); Sun, 22 Aug 2010 15:27:13 -0400 Date: Sun, 22 Aug 2010 21:27:05 +0200 From: Andi Kleen To: Mathieu Desnoyers Cc: LKML , ltt-dev@lists.casi.polymtl.ca, Linus Torvalds , Andrew Morton , Ingo Molnar , Peter Zijlstra , Steven Rostedt , Frederic Weisbecker , Thomas Gleixner , Christoph Hellwig , Li Zefan , Lai Jiangshan , Johannes Berg , Masami Hiramatsu , Arnaldo Carvalho de Melo , Tom Zanussi , KOSAKI Motohiro , Andi Kleen , Alexander Shishkin , Russell King - ARM Linux , linux-arm-kernel@lists.infradead.org, Imre Deak , Jamie Lokier , Alexey Dobriyan , "Kirill A. Shutemov" Subject: Re: [PATCH for -tip 1/2] kernel.h: add MAYBE_BUILD_BUG_ON_NOT_POWER_OF_2 Message-ID: <20100822192705.GE1771@one.firstfloor.org> References: <20100821141750.770348530@efficios.com> <20100821142215.023431313@efficios.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100821142215.023431313@efficios.com> User-Agent: Mutt/1.4.2.2i Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +/* Force a compilation error if condition is constant and not a power of 2 */ > +#define MAYBE_BUILD_BUG_ON_NOT_POWER_OF_2(n) \ > + MAYBE_BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) Looks super-ugly. IMHO just writing MAYBE_BUILD_BUG_ON(!n || n & (n - 1)) directly would be clear enough. If you really think that's unclear define a generic is_power_of_two() macro. -Andi