13434Sesaxe /* 23434Sesaxe * CDDL HEADER START 33434Sesaxe * 43434Sesaxe * The contents of this file are subject to the terms of the 53434Sesaxe * Common Development and Distribution License (the "License"). 63434Sesaxe * You may not use this file except in compliance with the License. 73434Sesaxe * 83434Sesaxe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93434Sesaxe * or http://www.opensolaris.org/os/licensing. 103434Sesaxe * See the License for the specific language governing permissions 113434Sesaxe * and limitations under the License. 123434Sesaxe * 133434Sesaxe * When distributing Covered Code, include this CDDL HEADER in each 143434Sesaxe * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153434Sesaxe * If applicable, add the following below this CDDL HEADER, with the 163434Sesaxe * fields enclosed by brackets "[]" replaced with your own identifying 173434Sesaxe * information: Portions Copyright [yyyy] [name of copyright owner] 183434Sesaxe * 193434Sesaxe * CDDL HEADER END 203434Sesaxe */ 213434Sesaxe /* 22*12149Srafael.vanoni@sun.com * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 233434Sesaxe */ 243434Sesaxe 253434Sesaxe #ifndef _BITSET_H 263434Sesaxe #define _BITSET_H 273434Sesaxe 283434Sesaxe #ifdef __cplusplus 293434Sesaxe extern "C" { 303434Sesaxe #endif 313434Sesaxe 323434Sesaxe #if (defined(_KERNEL) || defined(_KMEMUSER)) 333434Sesaxe #include <sys/bitmap.h> 343434Sesaxe #include <sys/types.h> 353434Sesaxe 363434Sesaxe typedef struct bitset { 373434Sesaxe ulong_t *bs_set; 383434Sesaxe uint_t bs_words; 39*12149Srafael.vanoni@sun.com uint_t bs_fanout; 403434Sesaxe } bitset_t; 413434Sesaxe 423434Sesaxe /* 433434Sesaxe * Bitset initialiation / teardown 443434Sesaxe */ 453434Sesaxe void bitset_init(bitset_t *); 46*12149Srafael.vanoni@sun.com void bitset_init_fanout(bitset_t *, uint_t); 473434Sesaxe void bitset_fini(bitset_t *); 483434Sesaxe 493434Sesaxe /* 503434Sesaxe * Resize / query a bitset's holding capacity 513434Sesaxe */ 523434Sesaxe void bitset_resize(bitset_t *, uint_t); 533434Sesaxe uint_t bitset_capacity(bitset_t *); 543434Sesaxe 553434Sesaxe /* 563434Sesaxe * Set / clear a bit in the set 573434Sesaxe */ 583434Sesaxe void bitset_add(bitset_t *, uint_t); 593434Sesaxe void bitset_del(bitset_t *, uint_t); 603434Sesaxe 613434Sesaxe /* 628408SEric.Saxe@Sun.COM * Atomic operations 638408SEric.Saxe@Sun.COM */ 648408SEric.Saxe@Sun.COM void bitset_atomic_add(bitset_t *, uint_t); 658408SEric.Saxe@Sun.COM void bitset_atomic_del(bitset_t *, uint_t); 668408SEric.Saxe@Sun.COM int bitset_atomic_test_and_add(bitset_t *, uint_t); 678408SEric.Saxe@Sun.COM int bitset_atomic_test_and_del(bitset_t *, uint_t); 688408SEric.Saxe@Sun.COM 698408SEric.Saxe@Sun.COM /* 703434Sesaxe * Bitset queries 713434Sesaxe */ 723434Sesaxe int bitset_in_set(bitset_t *, uint_t); 733434Sesaxe int bitset_is_null(bitset_t *); 743434Sesaxe uint_t bitset_find(bitset_t *); 753434Sesaxe 7610696SDavid.Hollister@Sun.COM /* 7710696SDavid.Hollister@Sun.COM * Bitset computations 7810696SDavid.Hollister@Sun.COM */ 7910696SDavid.Hollister@Sun.COM int bitset_and(bitset_t *, bitset_t *, bitset_t *); 8010696SDavid.Hollister@Sun.COM int bitset_or(bitset_t *, bitset_t *, bitset_t *); 8110696SDavid.Hollister@Sun.COM int bitset_xor(bitset_t *, bitset_t *, bitset_t *); 8210696SDavid.Hollister@Sun.COM 8310696SDavid.Hollister@Sun.COM /* 8410696SDavid.Hollister@Sun.COM * Miscellaneous bitset operations 8510696SDavid.Hollister@Sun.COM */ 8610696SDavid.Hollister@Sun.COM void bitset_zero(bitset_t *); 8710696SDavid.Hollister@Sun.COM void bitset_copy(bitset_t *, bitset_t *); 8810696SDavid.Hollister@Sun.COM int bitset_match(bitset_t *, bitset_t *); 8910696SDavid.Hollister@Sun.COM 903434Sesaxe #endif /* !_KERNEL && !_KMEMUSER */ 913434Sesaxe 923434Sesaxe #ifdef __cplusplus 933434Sesaxe } 943434Sesaxe #endif 953434Sesaxe 963434Sesaxe #endif /* _BITSET_H */ 97