Page MenuHomeFreeBSD

bitset: add BIT_FFS_AT() for finding the first bit set greater than a start bit
ClosedPublic

Authored by scottph on Aug 20 2020, 6:47 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 3, 11:30 PM
Unknown Object (File)
Nov 21 2024, 6:31 AM
Unknown Object (File)
Nov 15 2024, 4:18 PM
Unknown Object (File)
Nov 15 2024, 3:52 PM
Unknown Object (File)
Nov 15 2024, 3:19 PM
Unknown Object (File)
Nov 15 2024, 1:52 PM
Unknown Object (File)
Nov 4 2024, 5:34 PM
Unknown Object (File)
Oct 3 2024, 12:51 PM

Details

Summary

MFC after: 1 week
Sponsored by: Ampere Computing, Inc.

Diff Detail

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

Event Timeline

juan.molina_club.fr added inline comments.
share/man/man9/bitset.9
27 ↗(On Diff #76016)

Typo

share/man/man9/bitset.9
294 ↗(On Diff #76016)

For me it looks like 'greater or equal'.

sys/sys/bitset.h
241 ↗(On Diff #76016)

Why not implement this same as BIT_FFS, but start the loop not from __i = 0, but from __i = __bitset_word(s, start) ?

Then BIT_FFS() can be redefined as BIT_FFS_AT(s, p, 0). Of course, all this assuming my note about 'greater or equal' being true.

scottph added inline comments.
share/man/man9/bitset.9
294 ↗(On Diff #76016)

It would be greater-or-equal if you consider start as a 1-based index, or greater if you consider it 1-based. I tried to document everything as 1-based as that's also the return value of BIT_FFS, but I can change it around however.

sys/sys/bitset.h
241 ↗(On Diff #76016)

The old version was a sort-of transliteration of bitstring's bit_ffs_at, and then I had not redefined BIT_FFS() in terms of BIT_FFS_AT() because it seemed to be generating assembly for the mask even in the 0 start case. This version doesn't seem to have that problem so I've redefined BIT_FFS here.

Other than the small note, looks good.

sys/sys/bitset.h
234 ↗(On Diff #76039)

Don' you need to write this as BIT_FFS_AT((_s), (p), 0) ?

This revision is now accepted and ready to land.Aug 20 2020, 9:32 PM
This revision now requires review to proceed.Aug 21 2020, 7:16 AM
scottph added inline comments.
sys/sys/bitset.h
234 ↗(On Diff #76039)

I don't believe anything could go wrong without it, but I've added it for consistency with the surrounding code.

This revision is now accepted and ready to land.Aug 21 2020, 10:38 AM