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)
Feb 8 2024, 4:24 AM
Unknown Object (File)
Jan 27 2024, 2:47 PM
Unknown Object (File)
Jan 19 2024, 5:57 PM
Unknown Object (File)
Dec 23 2023, 6:59 AM
Unknown Object (File)
Dec 22 2023, 10:32 PM
Unknown Object (File)
Dec 22 2023, 9:44 AM
Unknown Object (File)
Dec 21 2023, 2:11 PM
Unknown Object (File)
Nov 27 2023, 10:51 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 Not Applicable
Unit
Tests Not Applicable

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.