Files
tegra-linux-noble/include/linux
Roland Dreier cc8ef6eb21 kernel.h: add BUILD_BUG_ON_NOT_POWER_OF_2()
Add BUILD_BUG_ON_NOT_POWER_OF_2()

When code relies on a constant being a power of 2:

	#define FOO	512	/* must be a power of 2 */

it would be nice to be able to do:

	BUILD_BUG_ON(!is_power_of_2(FOO));

However applying an inline function does not result in a compile-time
constant that can be used with BUILD_BUG_ON(), so trying that gives
results in:

	error: bit-field '<anonymous>' width not an integer constant

As suggested by akpm, rather than monkeying around with is_power_of_2()
and risking gcc warts about constant expressions, just create a macro
BUILD_BUG_ON_NOT_POWER_OF_2() to encapsulate this common requirement.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: David Dillow <dave@thedillows.org>
Cc: "Robert P. J. Day" <rpjday@crashcourse.ca>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-01-16 12:15:39 -08:00
..
2009-12-16 10:23:43 -08:00
2009-12-16 07:20:13 -08:00
2009-12-30 08:41:07 +01:00
2009-12-06 21:10:56 +01:00
2009-12-10 23:52:01 +00:00
2009-12-15 08:53:33 -08:00
2009-12-10 15:02:53 +01:00
2009-12-23 13:33:54 +01:00
2009-12-14 23:55:34 +01:00
2009-12-14 21:17:29 +01:00
2009-12-21 11:32:27 -05:00
2009-12-25 17:30:22 -08:00
2009-12-16 06:56:12 -08:00
2009-12-09 17:14:38 +11:00
2009-12-15 08:53:36 -08:00
2009-12-15 08:53:20 -08:00
2009-12-12 13:08:15 +01:00
2009-12-09 12:12:44 +02:00
2010-01-04 15:41:47 -08:00
2009-12-15 08:53:25 -08:00
2009-12-15 08:53:20 -08:00
2009-12-16 22:32:29 -05:00
2009-12-15 08:53:16 -08:00
2009-12-25 17:30:22 -08:00
2010-01-16 12:15:38 -08:00
2009-12-16 12:16:49 -05:00