public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will.deacon@arm.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: "torvalds@linux-foundation.org" <torvalds@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	Victor Kamensky <victor.kamensky@linaro.org>
Subject: Re: [PATCH] word-at-a-time: avoid undefined behaviour in zero_bytemask macro
Date: Thu, 1 May 2014 10:04:39 +0100	[thread overview]
Message-ID: <20140501090438.GA30166@arm.com> (raw)
In-Reply-To: <5361698B.4060607@zytor.com>

Hi Peter,

On Wed, Apr 30, 2014 at 10:22:19PM +0100, H. Peter Anvin wrote:
> On 04/23/2014 09:52 AM, Will Deacon wrote:
> > diff --git a/include/asm-generic/word-at-a-time.h b/include/asm-generic/word-at-a-time.h
> > index d3909effd725..d96deb443f18 100644
> > --- a/include/asm-generic/word-at-a-time.h
> > +++ b/include/asm-generic/word-at-a-time.h
> > @@ -50,11 +50,7 @@ static inline bool has_zero(unsigned long val, unsigned long *data, const struct
> >  }
> >  
> >  #ifndef zero_bytemask
> > -#ifdef CONFIG_64BIT
> > -#define zero_bytemask(mask)	(~0ul << fls64(mask))
> > -#else
> > -#define zero_bytemask(mask)	(~0ul << fls(mask))
> > -#endif /* CONFIG_64BIT */
> > -#endif /* zero_bytemask */
> > +#define zero_bytemask(mask) (~0ul << __fls(mask) << 1)
> > +#endif
> >  
> >  #endif /* _ASM_WORD_AT_A_TIME_H */
> > 
> 
> Why not:
> 
> #define zero_bytemask(mask) (~1ul << __fls(mask))

Yup, that'll work too -- it produces an identical disassembly for arm64.

Will

      reply	other threads:[~2014-05-01  9:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-23 16:52 [PATCH] word-at-a-time: avoid undefined behaviour in zero_bytemask macro Will Deacon
2014-04-30 21:22 ` H. Peter Anvin
2014-05-01  9:04   ` Will Deacon [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=20140501090438.GA30166@arm.com \
    --to=will.deacon@arm.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=victor.kamensky@linaro.org \
    /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