lkml.org 
[lkml]   [2017]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] kernel.h: add IS_PTR_ALIGNED() macro
    On Wed, 29 Mar 2017 19:22:10 +0900 Masahiro Yamada <yamada.masahiro@socionext.com> wrote:

    > We often check if a pointer has a specific alignment. Because the
    > '&' (bitwise AND) operator cannot take a pointer for the operand,
    > so we need a cast like, IS_ALIGNED((unsigned long)p, a).
    >
    > IS_PTR_ALIGNED will be useful as a shorthand.
    >
    > ...
    >
    > --- a/include/linux/kernel.h
    > +++ b/include/linux/kernel.h
    > @@ -50,6 +50,7 @@
    > #define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask))
    > #define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
    > #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
    > +#define IS_PTR_ALIGNED(p, a) (IS_ALIGNED((unsigned long)p, a))
    >
    > /* generic data direction definitions */
    > #define READ 0

    It would be nice to see some conversions which actually use this new
    macro.

    \
     
     \ /
      Last update: 2017-03-29 23:39    [W:6.898 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site