lkml.org 
[lkml]   [2008]   [Feb]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[rfc 02/10] Pageflags: Introduce macros to generate page flag functions
    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
    TESTPAGEFLAG Create additional atomic set function
    SETPAGEFLAG Create additional atomic clear function
    __TESTPAGEFLAG Create additional atomic set function
    __SETPAGEFLAG Create additional atomic clear function

    Signed-off-by: Christoph Lameter <clameter@sgi.com>

    ---
    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) \
    --


    \
     
     \ /
      Last update: 2008-03-01 05:11    [W:0.023 / U:3.104 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site