tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ffs64 used with ilog2 for sizes <= 4 bytes?



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


--
Jean-Yves Migeon
jeanyves.migeon%free.fr@localhost


Home | Main Index | Thread Index | Old Index