pageflags: introduce macros to generate page flag functions
authorChristoph Lameter <clameter@sgi.com>
Mon, 28 Apr 2008 09:12:49 +0000 (02:12 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 28 Apr 2008 15:58:22 +0000 (08:58 -0700)
Introduce a set of macros that generate functions to handle page flags.

A page flag function group typically starts with either

SETPAGEFLAG(<part of function name>,<part of PG_ flagname>)

to create a set of page flag operations that are atomic. Or

__SETPAGEFLAG(<part of function name>,<part of PG_ flagname)

to create a set of page flag operations that are not atomic.

Then additional operations can be added using the following macros

TESTSCFLAG Create additional atomic test-and-set and
test-and-clear functions

TESTSETFLAG Create additional test and set function
TESTCLEARFLAG Create additional test and clear function
SETPAGEFLAG Create additional atomic set function
CLEARPAGEFLAG Create additional atomic clear function
__TESTPAGEFLAG Create additional non atomic set function
__SETPAGEFLAG Create additional non atomic clear function

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Cc: Andy Whitcroft <apw@shadowen.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/page-flags.h

index 00e55e23b7775bd1221e031a1338212a4ebfb176..e5bddbfcf7aeef24845939110d3c8386024b26c1 100644 (file)
@@ -108,6 +108,47 @@ enum pageflags {
 
 #ifndef __GENERATING_BOUNDS_H
 
+/*
+ * Macros to create function definitions for page flags
+ */
+#define TESTPAGEFLAG(uname, lname)                                     \
+static inline int Page##uname(struct page *page)                       \
+                       { return test_bit(PG_##lname, &page->flags); }
+
+#define SETPAGEFLAG(uname, lname)                                      \
+static inline void SetPage##uname(struct page *page)                   \
+                       { set_bit(PG_##lname, &page->flags); }
+
+#define CLEARPAGEFLAG(uname, lname)                                    \
+static inline void ClearPage##uname(struct page *page)                 \
+                       { clear_bit(PG_##lname, &page->flags); }
+
+#define __SETPAGEFLAG(uname, lname)                                    \
+static inline void __SetPage##uname(struct page *page)                 \
+                       { __set_bit(PG_##lname, &page->flags); }
+
+#define __CLEARPAGEFLAG(uname, lname)                                  \
+static inline void __ClearPage##uname(struct page *page)               \
+                       { __clear_bit(PG_##lname, &page->flags); }
+
+#define TESTSETFLAG(uname, lname)                                      \
+static inline int TestSetPage##uname(struct page *page)                        \
+               { return test_and_set_bit(PG_##lname, &page->flags); }
+
+#define TESTCLEARFLAG(uname, lname)                                    \
+static inline int TestClearPage##uname(struct page *page)              \
+               { return test_and_clear_bit(PG_##lname, &page->flags); }
+
+
+#define PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname)              \
+       SETPAGEFLAG(uname, lname) CLEARPAGEFLAG(uname, lname)
+
+#define __PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname)            \
+       __SETPAGEFLAG(uname, lname)  __CLEARPAGEFLAG(uname, lname)
+
+#define TESTSCFLAG(uname, lname)                                       \
+       TESTSETFLAG(uname, lname) TESTCLEARFLAG(uname, lname)
+
 /*
  * Manipulation of page state flags
  */