tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: ffs64 used with ilog2 for sizes <= 4 bytes?
On 03.05.2011 17:07, Jean-Yves Migeon wrote:
> Hi all,
>
> Is ilog2() supposed to use fls64(), even for 4 bytes long types?
>
> The test looks rather wrong to me, but before committing anything really
> stupid... 64 bits ops on 32 bits systems are a tad more heavyweight.
>
> Index: sys/sys/bitops.h
> ===================================================================
> RCS file: /cvsroot/src/sys/sys/bitops.h,v
> retrieving revision 1.7
> diff -u -p -r1.7 bitops.h
> --- sys/sys/bitops.h 21 Mar 2010 14:28:15 -0000 1.7
> +++ sys/sys/bitops.h 3 May 2011 15:02:46 -0000
> @@ -255,7 +255,7 @@ fls64(uint64_t _n)
> _ilog2_helper(_n, 2) \
> _ilog2_helper(_n, 1) \
> _ilog2_helper(_n, 0) \
> - -1) : ((sizeof(_n) >= 4 ? fls64(_n) : fls32(_n)) - 1) \
> + -1) : ((sizeof(_n) > 4 ? fls64(_n) : fls32(_n)) - 1) \
> )
>
> static __inline void
Had a look at the Linux version, and the test is "reversed" (sizeof(n)
<= 4 ? ilog2_u32 : ilog2_u64). I'll just commit my patch in a day or two
just to give some more time for comments. Although I don't expect much
discussion from now on.
--
Jean-Yves Migeon
jeanyves.migeon%free.fr@localhost
Home |
Main Index |
Thread Index |
Old Index