1 /**************************************************************************
3 * Copyright 2009 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
32 * @author Jose Fonseca <jfonseca@vmware.com>
35 #ifndef U_HANDLE_BITMASK_H_
36 #define U_HANDLE_BITMASK_H_
44 #define UTIL_BITMASK_INVALID_INDEX (~0U)
48 * Abstract data type to represent arbitrary set of bits.
54 util_bitmask_create(void);
58 * Search a cleared bit and set it.
60 * It searches for the first cleared bit.
62 * Returns the bit index on success, or UTIL_BITMASK_INVALID_INDEX on out of
63 * memory growing the bitmask.
66 util_bitmask_add(struct util_bitmask
*bm
);
71 * Returns the input index on success, or UTIL_BITMASK_INVALID_INDEX on out of
72 * memory growing the bitmask.
75 util_bitmask_set(struct util_bitmask
*bm
,
79 util_bitmask_clear(struct util_bitmask
*bm
,
83 util_bitmask_get(struct util_bitmask
*bm
,
88 util_bitmask_destroy(struct util_bitmask
*bm
);
92 * Search for the first set bit.
94 * Returns UTIL_BITMASK_INVALID_INDEX if a set bit cannot be found.
97 util_bitmask_get_first_index(struct util_bitmask
*bm
);
101 * Search for the first set bit, starting from the giving index.
103 * Returns UTIL_BITMASK_INVALID_INDEX if a set bit cannot be found.
106 util_bitmask_get_next_index(struct util_bitmask
*bm
,
114 #endif /* U_HANDLE_BITMASK_H_ */