Re: [RFC, 2.6] a simple FIFO implementation

From: Ryan Cumming
Date: Sat Sep 18 2004 - 02:58:38 EST


On Friday 17 September 2004 20:41, Kyle Moffett wrote:
> This should probably be __const__, which is a stricter class of
> __pure__.
> The "__pure__" attribute means it has no side effects, whereas the
> "__const__" attribute means that it also _only_ depends on its
> arguments,
> not on any global memory or the data at any pointers passed to it.

Good call. I was just copying the __pure__ from long_log2 function in
kernel.h, which looks like it should be __const__ too.

Here's a third try, with Andrew's and your suggestions.

-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_const__ roundup_pow_of_two(unsigned long x)
+{
+ return (1UL << fls(x - 1));
+}

extern int printk_ratelimit(void);
extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);

Attachment: pgp00000.pgp
Description: PGP signature