Re: [RFC, 2.6] a simple FIFO implementation
From: Ryan Cumming
Date: Fri Sep 17 2004 - 17:28:36 EST
On Friday 17 September 2004 15:00, Andrea Arcangeli wrote:
> This is likely a candidate to go in include/linux/kernel.h (maybe under
> the name roundup_pow_of_two to avoid misunderstanding with the much more
> common PAGE_SIZE roundups)
How does this look?
-Ryan
--- include/linux/kernel.h 2004-09-16 06:38:19.000000000 -0700
+++ include/linux/kernel.h 2004-09-17 15:12:20.598844004 -0700
@@ -12,6 +12,7 @@
#include <linux/stddef.h>
#include <linux/types.h>
#include <linux/compiler.h>
+#include <linux/bitops.h>
#include <asm/byteorder.h>
#include <asm/bug.h>
@@ -111,6 +112,10 @@
return r;
}
+static inline unsigned long __attribute_pure__ roundup_pow_of_two(int x)
+{
+ return (1UL << fls(x));
+}
extern int printk_ratelimit(void);
extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
Attachment:
pgp00000.pgp
Description: PGP signature