1 .\" Copyright (c) 1989 The Regents of the University of California.
2 .\" All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
7 .\" Redistribution and use in source and binary forms are permitted
8 .\" provided that the above copyright notice and this paragraph are
9 .\" duplicated in all such forms and that any documentation,
10 .\" advertising materials, and other materials related to such
11 .\" distribution and use acknowledge that the software was developed
12 .\" by the University of California, Berkeley. The name of the
13 .\" University may not be used to endorse or promote products derived
14 .\" from this software without specific prior written permission.
15 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16 .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 .\" @(#)bitstring.3 5.1 (Berkeley) 12/13/89
21 .TH BITSTRING 3 "December 13, 1989"
24 bit_alloc, bit_clear, bit_decl, bit_ffs, bit_nclear, bit_nset,
25 bit_set, bitstr_size, bit_test \- bit-string manipulation macros
29 #include <bitstring.h>
31 name = bit_alloc(nbits)
43 bit_ffc(name, nbits, value)
47 bit_ffs(name, nbits, value)
51 bit_nclear(name, start, stop)
55 bit_nset(name, start, stop)
72 These macros operate on strings of bits.
75 returns a pointer of type
77 to sufficient space to store
79 bits, or NULL if no space is available.
82 is a macro for allocating sufficient space to store
87 returns the number of elements of type
92 This is useful for copying bit strings.
97 clear or set the zero-based numbered bit
105 set or clear the zero-based numbered bits from
113 evaluates to zero if the zero-based numbered bit
117 is set, and non-zero otherwise.
122 to the zero-based number of the first bit set in the array of
133 to the zero-based number of the first bit not set in the array of
144 #include <bitstring.h>
147 #define LPR_BUSY_BIT 0
148 #define LPR_FORMAT_BIT 1
149 #define LPR_DOWNLOAD_BIT 2
151 #define LPR_AVAILABLE_BIT 9
152 #define LPR_MAX_BITS 10
156 bitstr_t bit_decl(bitlist, LPR_MAX_BITS);
158 bit_nclear(bitlist, 0, LPR_MAX_BITS - 1);
160 if (!bit_test(bitlist, LPR_BUSY_BIT)) {
161 bit_clear(bitlist, LPR_FORMAT_BIT);
162 bit_clear(bitlist, LPR_DOWNLOAD_BIT);
163 bit_set(bitlist, LPR_AVAILABLE_BIT);