Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1612379

Re: [PATCH] kernel.h: add IS_PTR_ALIGNED() macro

From Andrew Morton <akpm@linux-foundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH] kernel.h: add IS_PTR_ALIGNED() macro
Date 2017-03-29 23:40 +0200
Message-ID <tqttU-4o9-7@gated-at.bofh.it> (permalink)
References <tqj1w-5wl-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] kernel.h: add IS_PTR_ALIGNED() macro Masahiro Yamada <yamada.masahiro@socionext.com> - 2017-03-29 12:30 +0200
  Re: [PATCH] kernel.h: add IS_PTR_ALIGNED() macro Andrew Morton <akpm@linux-foundation.org> - 2017-03-29 23:40 +0200
  Re: [PATCH] kernel.h: add IS_PTR_ALIGNED() macro "H. Peter Anvin" <hpa@zytor.com> - 2017-03-29 23:40 +0200
    Re: [PATCH] kernel.h: add IS_PTR_ALIGNED() macro Masahiro Yamada <yamada.masahiro@socionext.com> - 2017-03-30 04:00 +0200
      Re: [PATCH] kernel.h: add IS_PTR_ALIGNED() macro "H. Peter Anvin" <hpa@zytor.com> - 2017-03-30 05:50 +0200
        Re: [PATCH] kernel.h: add IS_PTR_ALIGNED() macro Masahiro Yamada <yamada.masahiro@socionext.com> - 2017-03-30 17:30 +0200

csiph-web