xref: /titanic_50/usr/src/uts/common/sys/bitset.h (revision fb2f18f820d90b001aea4fb27dd654bc1263c440)
1*fb2f18f8Sesaxe /*
2*fb2f18f8Sesaxe  * CDDL HEADER START
3*fb2f18f8Sesaxe  *
4*fb2f18f8Sesaxe  * The contents of this file are subject to the terms of the
5*fb2f18f8Sesaxe  * Common Development and Distribution License (the "License").
6*fb2f18f8Sesaxe  * You may not use this file except in compliance with the License.
7*fb2f18f8Sesaxe  *
8*fb2f18f8Sesaxe  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*fb2f18f8Sesaxe  * or http://www.opensolaris.org/os/licensing.
10*fb2f18f8Sesaxe  * See the License for the specific language governing permissions
11*fb2f18f8Sesaxe  * and limitations under the License.
12*fb2f18f8Sesaxe  *
13*fb2f18f8Sesaxe  * When distributing Covered Code, include this CDDL HEADER in each
14*fb2f18f8Sesaxe  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*fb2f18f8Sesaxe  * If applicable, add the following below this CDDL HEADER, with the
16*fb2f18f8Sesaxe  * fields enclosed by brackets "[]" replaced with your own identifying
17*fb2f18f8Sesaxe  * information: Portions Copyright [yyyy] [name of copyright owner]
18*fb2f18f8Sesaxe  *
19*fb2f18f8Sesaxe  * CDDL HEADER END
20*fb2f18f8Sesaxe  */
21*fb2f18f8Sesaxe /*
22*fb2f18f8Sesaxe  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*fb2f18f8Sesaxe  * Use is subject to license terms.
24*fb2f18f8Sesaxe  */
25*fb2f18f8Sesaxe 
26*fb2f18f8Sesaxe #ifndef	_BITSET_H
27*fb2f18f8Sesaxe #define	_BITSET_H
28*fb2f18f8Sesaxe 
29*fb2f18f8Sesaxe #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*fb2f18f8Sesaxe 
31*fb2f18f8Sesaxe #ifdef	__cplusplus
32*fb2f18f8Sesaxe extern "C" {
33*fb2f18f8Sesaxe #endif
34*fb2f18f8Sesaxe 
35*fb2f18f8Sesaxe #if (defined(_KERNEL) || defined(_KMEMUSER))
36*fb2f18f8Sesaxe #include <sys/bitmap.h>
37*fb2f18f8Sesaxe #include <sys/types.h>
38*fb2f18f8Sesaxe 
39*fb2f18f8Sesaxe typedef struct bitset {
40*fb2f18f8Sesaxe 	ulong_t	*bs_set;
41*fb2f18f8Sesaxe 	uint_t	bs_words;
42*fb2f18f8Sesaxe } bitset_t;
43*fb2f18f8Sesaxe 
44*fb2f18f8Sesaxe /*
45*fb2f18f8Sesaxe  * Bitset initialiation / teardown
46*fb2f18f8Sesaxe  */
47*fb2f18f8Sesaxe void		bitset_init(bitset_t *);
48*fb2f18f8Sesaxe void		bitset_fini(bitset_t *);
49*fb2f18f8Sesaxe 
50*fb2f18f8Sesaxe /*
51*fb2f18f8Sesaxe  * Resize / query a bitset's holding capacity
52*fb2f18f8Sesaxe  */
53*fb2f18f8Sesaxe void		bitset_resize(bitset_t *, uint_t);
54*fb2f18f8Sesaxe uint_t		bitset_capacity(bitset_t *);
55*fb2f18f8Sesaxe 
56*fb2f18f8Sesaxe /*
57*fb2f18f8Sesaxe  * Set / clear a bit in the set
58*fb2f18f8Sesaxe  */
59*fb2f18f8Sesaxe void		bitset_add(bitset_t *, uint_t);
60*fb2f18f8Sesaxe void		bitset_del(bitset_t *, uint_t);
61*fb2f18f8Sesaxe 
62*fb2f18f8Sesaxe /*
63*fb2f18f8Sesaxe  * Bitset queries
64*fb2f18f8Sesaxe  */
65*fb2f18f8Sesaxe int		bitset_in_set(bitset_t *, uint_t);
66*fb2f18f8Sesaxe int		bitset_is_null(bitset_t *);
67*fb2f18f8Sesaxe uint_t		bitset_find(bitset_t *);
68*fb2f18f8Sesaxe 
69*fb2f18f8Sesaxe 
70*fb2f18f8Sesaxe #endif	/* !_KERNEL && !_KMEMUSER */
71*fb2f18f8Sesaxe 
72*fb2f18f8Sesaxe #ifdef	__cplusplus
73*fb2f18f8Sesaxe }
74*fb2f18f8Sesaxe #endif
75*fb2f18f8Sesaxe 
76*fb2f18f8Sesaxe #endif /* _BITSET_H */
77