From: andi@firstfloor•org (Andi Kleen)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH for -tip 1/2] kernel.h: add MAYBE_BUILD_BUG_ON_NOT_POWER_OF_2
Date: Sun, 22 Aug 2010 21:27:05 +0200 [thread overview]
Message-ID: <20100822192705.GE1771@one.firstfloor.org> (raw)
In-Reply-To: <20100821142215.023431313@efficios.com>
> +/* 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
next prev parent reply other threads:[~2010-08-22 19:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20100821141750.770348530@efficios.com>
2010-08-21 14:17 ` [PATCH for -tip 1/2] kernel.h: add MAYBE_BUILD_BUG_ON_NOT_POWER_OF_2 Mathieu Desnoyers
2010-08-21 18:26 ` Alexey Dobriyan
2010-08-21 18:40 ` Mathieu Desnoyers
2010-08-21 19:44 ` Alexey Dobriyan
2010-08-22 19:27 ` Andi Kleen [this message]
2010-08-22 19:38 ` Mathieu Desnoyers
2010-08-22 20:16 ` Anca Emanuel
2010-08-22 21:03 ` Mathieu Desnoyers
2010-08-21 14:17 ` [PATCH for -tip 2/2] Create generic alignment API (v9) Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100822192705.GE1771@one.firstfloor.org \
--to=andi@firstfloor$(echo .)org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox