* [PATCH] include/linux/log2.h: mark is_power_of_2 __always_inline
@ 2024-08-09 16:11 Mark Harmstone
0 siblings, 0 replies; only message in thread
From: Mark Harmstone @ 2024-08-09 16:11 UTC (permalink / raw)
To: linux-kernel; +Cc: Mark Harmstone
For debugging purposes, it would be useful to be able to compile the whole
kernel with -fno-inline. Unfortunately BUILD_BUG_ON statements with
is_power_of_2 prevent this from working, as the condition needs to be
evaluable at compile-time. Marking is_power_of_2 as __always_inline,
rather than just normal inline, fixes this.
Signed-off-by: Mark Harmstone <maharmstone@fb.com>
---
include/linux/log2.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/log2.h b/include/linux/log2.h
index 9f30d087a128..1366cb688a6d 100644
--- a/include/linux/log2.h
+++ b/include/linux/log2.h
@@ -41,7 +41,7 @@ int __ilog2_u64(u64 n)
* *not* considered a power of two.
* Return: true if @n is a power of 2, otherwise false.
*/
-static inline __attribute__((const))
+static __always_inline __attribute__((const))
bool is_power_of_2(unsigned long n)
{
return (n != 0 && ((n & (n - 1)) == 0));
--
2.44.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-08-09 16:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-09 16:11 [PATCH] include/linux/log2.h: mark is_power_of_2 __always_inline Mark Harmstone
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®