Page MenuHomeFreeBSD

bitstring(3): Add bitstring traversal macros.
ClosedPublic

Authored by wulf on Aug 8 2021, 10:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 18, 4:37 AM
Unknown Object (File)
Fri, Nov 7, 5:44 AM
Unknown Object (File)
Wed, Nov 5, 8:46 PM
Unknown Object (File)
Wed, Nov 5, 5:59 PM
Unknown Object (File)
Wed, Oct 29, 5:47 PM
Unknown Object (File)
Wed, Oct 29, 5:32 PM
Unknown Object (File)
Wed, Oct 29, 5:21 PM
Unknown Object (File)
Wed, Oct 29, 5:17 PM
Subscribers

Details

Summary

The macro bit_foreach() traverses all set bits in the bitstring in the
forward direction, assigning each location in turn to variable.

The macro bit_foreach_at() traverses all set bits in the bitstring in
the forward direction at or after the zero-based bit index, assigning
each location in turn to variable.

I am going to use them in future evdev and hms(4) work.

The bit_foreach_unset() and bit_foreach_unset_at() macros which
traverses unset bits are implemented for completeness.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

wulf requested review of this revision.Aug 8 2021, 10:39 PM

Seems harmless.

sys/sys/bitstring.h
430

Nitpick: "in a bitstr" is present in line 422, but absent here. A comma is present here, but absent there.

This revision is now accepted and ready to land.Aug 9 2021, 9:10 AM
asomers requested changes to this revision.Aug 9 2021, 1:58 PM

You should also add new test cases to tests/sys/sys/bitstring_test.c .

This revision now requires changes to proceed.Aug 9 2021, 1:58 PM
  1. Add test cases.
  2. Make comments uniform.
wulf marked an inline comment as done.Aug 11 2021, 8:40 PM
wulf added inline comments.
sys/sys/bitstring.h
430

It was caused by "81-char line lenght" problem. Fixed.

This revision is now accepted and ready to land.Aug 11 2021, 11:18 PM
This revision was automatically updated to reflect the committed changes.
wulf marked an inline comment as done.