Re: [PATCH] asm-generic/bitops/fls64.h

Nickolay Vinogradov
2008-05-13T14:48:07Z

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