public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Andreas Schwab <schwab@suse.de>
Cc: Russell King <rmk+lkml@arm.linux.org.uk>,
	Alexander van Heukelum <heukelum@fastmail.fm>,
	Nickolay Vinogradov <nickolay@protei.ru>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] asm-generic/bitops/fls64.h
Date: Tue, 13 May 2008 09:11:11 -0700	[thread overview]
Message-ID: <20080513091111.bd9437c1.akpm@linux-foundation.org> (raw)
In-Reply-To: <je7idyw9ua.fsf@sykes.suse.de>

On Tue, 13 May 2008 16:35:25 +0200 Andreas Schwab <schwab@suse.de> wrote:

> Russell King <rmk+lkml@arm.linux.org.uk> writes:
> 
> > On Tue, May 13, 2008 at 03:24:13PM +0200, Alexander van Heukelum wrote:
> >> On Tue, 13 May 2008 16:29:04 +0400, "Nickolay Vinogradov"
> >> <nickolay@protei.ru> said:
> >> > Alexander van Heukelum &#1087;&#1080;&#1096;&#1077;&#1090;:
> >> > 
> >> > > Hi Nickolay,
> >> > > 
> >> > > The change is ok, I guess, but the cast should be a no-op (fls
> >> > > takes an int, which is always 32 bit in linux). What is the problem
> >> > > you are seeing? Does fls64() return a wrong value in some cases? If
> >> > > so, what cpu? Which values?
> >> > > 
> >> > > Why would this be a bug on big endian systems only? There is no
> >> > > pointer magic involved, so the compiler should take care of the
> >> > > casts in a correct way.
> >> > > 
> >> > > Maybe you see a compiler warning? Which compiler version?
> >> > > 
> >> > > (also note that current (development) kernels now have separate
> >> > > versions for 32-bit and 64-bit environments.)
> >> > 
> >> > Because fls() is a macro for asm-arm:
> >> > 
> >> > #define fls(x) \
> >> >          ( __builtin_constant_p(x) ? constant_fls(x) : \
> >> >          ({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 
> >> > 32-__r; }) )
> >> > 
> >> > We can fix it right here:
> >
> > No.  "fls" is for finding the last set bit in an _int_.  It is not
> > supposed to have random crap passed to it, such as types longer than
> > sizeof(int).
> 
> If you write fls as an (inline) function then the argument is implicitly
> converted.
> 

Yes, and that's what other architectures do.

It's not pretty, but I do think the arm implementation should zap the
upper 32 bits as other architectures do, and as one would expect from
the usual C type conversion rules.

Converting it to a C implementation would be a suitable means...

      reply	other threads:[~2008-05-13 16:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-04 18:58 [PATCH] asm-generic/bitops/fls64.h Виноградов Николай Михайлович
2008-05-12 21:45 ` Andrew Morton
2008-05-13 10:43   ` Nickolay Vinogradov
2008-05-13 15:31     ` Andrew Morton
2008-05-13 15:45       ` Nickolay Vinogradov
2008-05-13 11:17 ` Alexander van Heukelum
2008-05-13 12:29   ` Nickolay Vinogradov
2008-05-13 13:24     ` Alexander van Heukelum
2008-05-13 13:58       ` Russell King
2008-05-13 14:24         ` Alexander van Heukelum
2008-05-13 14:46           ` Nickolay Vinogradov
2008-05-13 14:35         ` Andreas Schwab
2008-05-13 16:11           ` 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=20080513091111.bd9437c1.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=heukelum@fastmail.fm \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickolay@protei.ru \
    --cc=rmk+lkml@arm.linux.org.uk \
    --cc=schwab@suse.de \
    /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