.\" Copyright (c) 1989 The Regents of the University of California.
.\" This code is derived from software contributed to Berkeley by
.\" %sccs.include.redist.man%
.\" @(#)bitstring.3 5.3 (Berkeley) %G%
bit_alloc, bit_clear, bit_decl, bit_ffs, bit_nclear, bit_nset,
bit_set, bitstr_size, bit_test \- bit-string manipulation macros
bit_ffc(name, nbits, value)
bit_ffs(name, nbits, value)
bit_nclear(name, start, stop)
bit_nset(name, start, stop)
These macros operate on strings of bits.
returns a pointer of type
to sufficient space to store
bits, or NULL if no space is available.
is a macro for allocating sufficient space to store
returns the number of elements of type
This is useful for copying bit strings.
clear or set the zero-based numbered bit
set or clear the zero-based numbered bits from
evaluates to zero if the zero-based numbered bit
is set, and non-zero otherwise.
stores in the location referenced by
the zero-based number of the first bit set in the array of
If no bits are set, the location referenced by
stores in the location referenced by
the zero-based number of the first bit not set in the array of
If all bits are set, the location referenced by
The arguments to these macros are evaluated only once and may safely
#define LPR_DOWNLOAD_BIT 2
#define LPR_AVAILABLE_BIT 9
bitstr_t bit_decl(bitlist, LPR_MAX_BITS);
bit_nclear(bitlist, 0, LPR_MAX_BITS - 1);
if (!bit_test(bitlist, LPR_BUSY_BIT)) {
bit_clear(bitlist, LPR_FORMAT_BIT);
bit_clear(bitlist, LPR_DOWNLOAD_BIT);
bit_set(bitlist, LPR_AVAILABLE_BIT);