Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761418AbYCAEHq (ORCPT ); Fri, 29 Feb 2008 23:07:46 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751141AbYCAEGs (ORCPT ); Fri, 29 Feb 2008 23:06:48 -0500 Received: from netops-testserver-3-out.sgi.com ([192.48.171.28]:34378 "EHLO relay.sgi.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751451AbYCAEGX (ORCPT ); Fri, 29 Feb 2008 23:06:23 -0500 Message-Id: <20080301040620.275745501@sgi.com> References: <20080301040534.797979115@sgi.com> User-Agent: quilt/0.46-1 Date: Fri, 29 Feb 2008 20:05:36 -0800 From: Christoph Lameter To: linux-kernel@vger.kernel.org Cc: Mel Gorman Cc: Nick Piggin Cc: Rik van Riel Cc: Andrew Morton Cc: apw@shadowen.org Cc: linux-mm@kback.org Subject: [rfc 02/10] Pageflags: Introduce macros to generate page flag functions Content-Disposition: inline; filename=pageflags-add-macros Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3118 Lines: 91 Introduce a set of macros that generate functions to handle page flags. A page flag function group typically starts with either SETPAGEFLAG(,) to create a set of page flag operations that are atomic. Or __SETPAGEFLAG(, --- include/linux/page-flags.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) Index: linux-2.6/include/linux/page-flags.h =================================================================== --- linux-2.6.orig/include/linux/page-flags.h 2008-02-29 19:14:30.000000000 -0800 +++ linux-2.6/include/linux/page-flags.h 2008-02-29 19:15:28.000000000 -0800 @@ -103,6 +103,47 @@ enum pageflags { }; /* + * 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); } + +#define SETPAGEFLAG(uname, lname) \ +static inline void SetPage##uname(struct page *page) \ + { set_bit(PG_##lname, page); } + +#define CLEARPAGEFLAG(uname, lname) \ +static inline void ClearPage##uname(struct page *page) \ + { clear_bit(PG_##lname, page); } + +#define __SETPAGEFLAG(uname, lname) \ +static inline void __SetPage##uname(struct page *page) \ + { __set_bit(PG_##lname, page); } + +#define __CLEARPAGEFLAG(uname, lname) \ +static inline void __ClearPage##uname(struct page *page) \ + { __clear_bit(PG_##lname, page); } + +#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 */ #define PageLocked(page) \ -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/