mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] log2: Fix declaration of __roundup_pow_of_two
@ 2013-02-26 16:51 Maxime Ripard
  2013-02-27  7:59 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Maxime Ripard @ 2013-02-26 16:51 UTC (permalink / raw)
  To: barebox

The roundup_pow_of_two function is making use of __roundup_pow_of_two
when the call to __builtin_constant_p fails, which is not implemented in
barebox.

Copied the code from Linux log2.h header.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 include/linux/log2.h |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/linux/log2.h b/include/linux/log2.h
index 389043a..d9913f0 100644
--- a/include/linux/log2.h
+++ b/include/linux/log2.h
@@ -54,6 +54,15 @@ bool is_power_of_2(unsigned long n)
 	return (n != 0 && ((n & (n - 1)) == 0));
 }
 
+/*
+ * round up to nearest power of two
+ */
+static inline __attribute__((const))
+unsigned long __roundup_pow_of_two(unsigned long n)
+{
+	return 1UL << fls(n - 1);
+}
+
 /**
  * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value
  * @n - parameter
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-02-27  7:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-26 16:51 [PATCH] log2: Fix declaration of __roundup_pow_of_two Maxime Ripard
2013-02-27  7:59 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox