summaryrefslogtreecommitdiff
path: root/include/linux/log2.h
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2017-06-23 15:55:15 +0200
committerSebastian Andrzej Siewior <bigeasy@linutronix.de>2017-06-23 15:55:15 +0200
commit5315486b2da90bcfa1ce5c791aafebb4c3534cf1 (patch)
treec3c215962edb82708210606574417efc1b84abe0 /include/linux/log2.h
parent351dce074b70b19c7f8b1b737a862577e822a508 (diff)
parent050639ef5810e8ad17fb6a426eff3c63e616350c (diff)
downloadlinux-rt-5315486b2da90bcfa1ce5c791aafebb4c3534cf1.tar.gz
Merge tag 'v4.9.33' into linux-4.9.y-rt
This is the 4.9.33 stable release Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Diffstat (limited to 'include/linux/log2.h')
-rw-r--r--include/linux/log2.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/include/linux/log2.h b/include/linux/log2.h
index f38fae23bdac..c373295f359f 100644
--- a/include/linux/log2.h
+++ b/include/linux/log2.h
@@ -194,6 +194,17 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
* ... and so on.
*/
-#define order_base_2(n) ilog2(roundup_pow_of_two(n))
+static inline __attribute_const__
+int __order_base_2(unsigned long n)
+{
+ return n > 1 ? ilog2(n - 1) + 1 : 0;
+}
+#define order_base_2(n) \
+( \
+ __builtin_constant_p(n) ? ( \
+ ((n) == 0 || (n) == 1) ? 0 : \
+ ilog2((n) - 1) + 1) : \
+ __order_base_2(n) \
+)
#endif /* _LINUX_LOG2_H */