Changeset View
Changeset View
Standalone View
Standalone View
share/man/man9/bitset.9
Show All 18 Lines | |||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||||
.\" POSSIBILITY OF SUCH DAMAGE. | .\" POSSIBILITY OF SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd December 31, 2020 | .Dd September 20, 2021 | ||||
.Dt BITSET 9 | .Dt BITSET 9 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm bitset(9) | .Nm bitset(9) | ||||
\(em | \(em | ||||
.Nm BITSET_DEFINE , | .Nm BITSET_DEFINE , | ||||
.Nm BITSET_T_INITIALIZER , | .Nm BITSET_T_INITIALIZER , | ||||
.Nm BITSET_FSET , | .Nm BITSET_FSET , | ||||
.Nm BIT_CLR , | .Nm BIT_CLR , | ||||
.Nm BIT_COPY , | .Nm BIT_COPY , | ||||
.Nm BIT_ISSET , | .Nm BIT_ISSET , | ||||
.Nm BIT_SET , | .Nm BIT_SET , | ||||
.Nm BIT_ZERO , | .Nm BIT_ZERO , | ||||
.Nm BIT_FILL , | .Nm BIT_FILL , | ||||
.Nm BIT_SETOF , | .Nm BIT_SETOF , | ||||
.Nm BIT_EMPTY , | .Nm BIT_EMPTY , | ||||
.Nm BIT_ISFULLSET , | .Nm BIT_ISFULLSET , | ||||
.Nm BIT_FFS , | .Nm BIT_FFS , | ||||
.Nm BIT_FFS_AT , | .Nm BIT_FFS_AT , | ||||
.Nm BIT_FLS , | .Nm BIT_FLS , | ||||
.Nm BIT_FOREACH_SET , | |||||
.Nm BIT_FOREACH_CLR , | |||||
.Nm BIT_COUNT , | .Nm BIT_COUNT , | ||||
.Nm BIT_SUBSET , | .Nm BIT_SUBSET , | ||||
.Nm BIT_OVERLAP , | .Nm BIT_OVERLAP , | ||||
.Nm BIT_CMP , | .Nm BIT_CMP , | ||||
.Nm BIT_OR , | .Nm BIT_OR , | ||||
.Nm BIT_OR2 , | .Nm BIT_OR2 , | ||||
.Nm BIT_AND , | .Nm BIT_AND , | ||||
.Nm BIT_AND2 , | .Nm BIT_AND2 , | ||||
Show All 31 Lines | |||||
.Ft bool | .Ft bool | ||||
.Fn BIT_ISFULLSET "const SETSIZE" "struct STRUCTNAME *bitset" | .Fn BIT_ISFULLSET "const SETSIZE" "struct STRUCTNAME *bitset" | ||||
.Ft long | .Ft long | ||||
.Fn BIT_FFS "const SETSIZE" "struct STRUCTNAME *bitset" | .Fn BIT_FFS "const SETSIZE" "struct STRUCTNAME *bitset" | ||||
.Ft long | .Ft long | ||||
.Fn BIT_FFS_AT "const SETSIZE" "struct STRUCTNAME *bitset" "long start" | .Fn BIT_FFS_AT "const SETSIZE" "struct STRUCTNAME *bitset" "long start" | ||||
.Ft long | .Ft long | ||||
.Fn BIT_FLS "const SETSIZE" "struct STRUCTNAME *bitset" | .Fn BIT_FLS "const SETSIZE" "struct STRUCTNAME *bitset" | ||||
.Fn BIT_FOREACH_SET "const SETSIZE" "int i" "const struct STRUCTNAME *bitset" | |||||
cem: `size_t bit` might be more consistent with other examples here. | |||||
.Fn BIT_FOREACH_CLR "const SETSIZE" "int i" "const struct STRUCTNAME *bitset" | |||||
.Ft long | .Ft long | ||||
.Fn BIT_COUNT "const SETSIZE" "struct STRUCTNAME *bitset" | .Fn BIT_COUNT "const SETSIZE" "struct STRUCTNAME *bitset" | ||||
.\" | |||||
.Ft bool | .Ft bool | ||||
.Fo BIT_SUBSET | .Fo BIT_SUBSET | ||||
.Fa "const SETSIZE" "struct STRUCTNAME *haystack" "struct STRUCTNAME *needle" | .Fa "const SETSIZE" "struct STRUCTNAME *haystack" "struct STRUCTNAME *needle" | ||||
.Fc | .Fc | ||||
.Ft bool | .Ft bool | ||||
.Fo BIT_OVERLAP | .Fo BIT_OVERLAP | ||||
.Fa "const SETSIZE" "struct STRUCTNAME *bitset1" "struct STRUCTNAME *bitset2" | .Fa "const SETSIZE" "struct STRUCTNAME *bitset1" "struct STRUCTNAME *bitset2" | ||||
.Fc | .Fc | ||||
▲ Show 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | |||||
.Xr fls 3 , | .Xr fls 3 , | ||||
to use the non-zero result of | to use the non-zero result of | ||||
.Fn BIT_FLS | .Fn BIT_FLS | ||||
as a | as a | ||||
.Fa bit | .Fa bit | ||||
index parameter to any other | index parameter to any other | ||||
.Nm | .Nm | ||||
macro, you must subtract one from the result. | macro, you must subtract one from the result. | ||||
.Pp | |||||
The | |||||
.Fn BIT_FOREACH_SET | |||||
macro can be used to iterate over all set bits in | |||||
.Fa bitset . | |||||
The index variable | |||||
.Fa i | |||||
must have been declared with type | |||||
.Ft int , | |||||
and upon each iteration | |||||
.Fa i | |||||
is set to the index of successive set bits. | |||||
The value of | |||||
.Fa i | |||||
after the loop terminates is undefined. | |||||
Similarly, | |||||
.Fn BIT_FOREACH_CLR | |||||
iterates over all clear bits in | |||||
.Fa bitset . | |||||
.Pp | .Pp | ||||
The | The | ||||
.Fn BIT_COUNT | .Fn BIT_COUNT | ||||
macro returns the total number of set bits in | macro returns the total number of set bits in | ||||
.Fa bitset . | .Fa bitset . | ||||
.Pp | .Pp | ||||
The | The | ||||
.Fn BIT_SUBSET | .Fn BIT_SUBSET | ||||
▲ Show 20 Lines • Show All 215 Lines • Show Last 20 Lines |
size_t bit might be more consistent with other examples here.