Page MenuHomeFreeBSD

Make bitpos() handle arguments with many set bits
ClosedPublic

Authored by dougm on May 10 2019, 6:56 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 10 2024, 3:41 AM
Unknown Object (File)
Dec 21 2023, 12:53 PM
Unknown Object (File)
Oct 14 2023, 3:31 AM
Unknown Object (File)
Oct 14 2023, 3:31 AM
Unknown Object (File)
Sep 11 2023, 7:11 PM
Unknown Object (File)
Aug 5 2023, 10:53 PM
Unknown Object (File)
Aug 4 2023, 6:34 AM
Unknown Object (File)
Aug 4 2023, 6:34 AM
Subscribers

Details

Summary

When bitpos can't be implemented with an inline ffs* instruction, change the binary search so that it does not depend on a single bit only being set in the bitmask. Use bitpos more generally, and avoid some clearing of bits to accommodate its current behavior.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

So why not use _Generic ?

subr_blist.c
224 ↗(On Diff #57283)

Is this case ever occur ? I believe daddr_t is always 64bit.
For this argument, you might actually add 'long'.

Apply _Generic instead of switch. Not previously acquainted with that construct.

subr_blist.c
224 ↗(On Diff #57283)

Where I'm testing, long long and long have the same size and the switch led to a compilation error.

Alan has suggested that someday he hopes to use a 32-bit daddr_t for 32-bit machines, which is why I bother sticking the int case in there.

subr_blist.c
224 ↗(On Diff #57283)

Did you tested with switch, or with _Generic. I would expect that you can use long with generic, since all three types 'long long', 'long' and 'int' are different, even if some of them have identical representation.

Add a 'long' case to the _Generic for bitpos, which compiles successfully.

This revision is now accepted and ready to land.May 10 2019, 10:46 PM
This revision was automatically updated to reflect the committed changes.

_Generic broke several builds. I'll prepare a patch to undo it, in case you don't have a better solution to offer.

_Generic broke several builds. I'll prepare a patch to undo it, in case you don't have a better solution to offer.

If you intend reverting the commit, you got the implicit approval.

Can you point me to the reports ?