public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nickolay Vinogradov <nickolay@protei.ru>
To: Alexander van Heukelum <heukelum@fastmail.fm>
Cc: Russell King <rmk+lkml@arm.linux.org.uk>,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] asm-generic/bitops/fls64.h
Date: Tue, 13 May 2008 18:46:46 +0400	[thread overview]
Message-ID: <4829A9D6.70106@protei.ru> (raw)
In-Reply-To: <1210688644.25548.1252907593@webmail.messagingengine.com>



Alexander van Heukelum пишет:

>> 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're going to pass long long (64-bit) arguments to fls, and then
>> cast them to a u32, you're truncating the value, and you'll get the
>> wrong answer if bit 33 or greater is set.  If you don't actually care
>> about the upper bits, don't pass a 64-bit quantity to fls().
>>
>> If you want to use fls with a long long, use fls64 instead.  Or for top
>> marks, use a u64 and fls64.
> 
> But that was the problem we began with: the generic fls64 passes an u64
> to fls. Nickolay's original patch solves that by putting a cast to u32
> in fls64. I did not, however, understand why the cast was needed.

The cast was needed because fls is a macro, not a function.

-- 
Nickolay Vinogradov
Protei Research and Development Center
St.Petersburg, 194044, Russia
Tel.: +7 812 449 47 27

  reply	other threads:[~2008-05-13 14:48 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 [this message]
2008-05-13 14:35         ` Andreas Schwab
2008-05-13 16:11           ` Andrew Morton

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=4829A9D6.70106@protei.ru \
    --to=nickolay@protei.ru \
    --cc=akpm@linux-foundation.org \
    --cc=heukelum@fastmail.fm \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk+lkml@arm.linux.org.uk \
    /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