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)
Nov 1 2024, 6:19 PM
Unknown Object (File)
Oct 21 2024, 10:33 PM
Unknown Object (File)
Sep 20 2024, 2:02 PM
Unknown Object (File)
Sep 19 2024, 10:28 AM
Unknown Object (File)
Sep 18 2024, 9:59 PM
Unknown Object (File)
Sep 17 2024, 4:38 PM
Unknown Object (File)
Sep 17 2024, 12:31 AM
Unknown Object (File)
Sep 16 2024, 2:35 AM
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.