mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
	"Jessica Yu" <jeyu@redhat.com>,
	"Johannes Berg" <johannes.berg@intel.com>,
	"Petr Mladek" <pmladek@suse.com>,
	"Larry Finger" <Larry.Finger@lwfinger.net>,
	linux-kernel@vger.kernel.org,
	"Gustavo Padovan" <gustavo.padovan@collabora.co.uk>,
	"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Luis de Bethencourt" <luisbg@osg.samsung.com>,
	"Josh Triplett" <josh@joshtriplett.org>
Subject: Re: [PATCH] kernel.h: add IS_PTR_ALIGNED() macro
Date: Wed, 29 Mar 2017 14:36:56 -0700	[thread overview]
Message-ID: <20170329143656.d89a2f139316df3f39a91db9@linux-foundation.org> (raw)
In-Reply-To: <1490782930-30429-1-git-send-email-yamada.masahiro@socionext.com>

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.

      parent reply	other threads:[~2017-03-29 21:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29 10:22 Masahiro Yamada
2017-03-29 21:24 ` H. Peter Anvin
2017-03-30  1:57   ` Masahiro Yamada
2017-03-30  3:29     ` H. Peter Anvin
2017-03-30 15:22       ` Masahiro Yamada
2017-03-29 21:36 ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170329143656.d89a2f139316df3f39a91db9@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=Larry.Finger@lwfinger.net \
    --cc=gustavo.padovan@collabora.co.uk \
    --cc=jeyu@redhat.com \
    --cc=johannes.berg@intel.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=luisbg@osg.samsung.com \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®