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_
39 #include "pipe/p_compiler.h"
47 #define UTIL_BITMASK_INVALID_INDEX (~0U)
51 * Abstract data type to represent arbitrary set of bits.
57 util_bitmask_create(void);
61 * Search a cleared bit and set it.
63 * It searches for the first cleared bit.
65 * Returns the bit index on success, or UTIL_BITMASK_INVALID_INDEX on out of
66 * memory growing the bitmask.
69 util_bitmask_add(struct util_bitmask
*bm
);
74 * Returns the input index on success, or UTIL_BITMASK_INVALID_INDEX on out of
75 * memory growing the bitmask.
78 util_bitmask_set(struct util_bitmask
*bm
,
82 util_bitmask_clear(struct util_bitmask
*bm
,
86 util_bitmask_get(struct util_bitmask
*bm
,
91 util_bitmask_destroy(struct util_bitmask
*bm
);
95 * Search for the first set bit.
97 * Returns UTIL_BITMASK_INVALID_INDEX if a set bit cannot be found.
100 util_bitmask_get_first_index(struct util_bitmask
*bm
);
104 * Search for the first set bit, starting from the giving index.
106 * Returns UTIL_BITMASK_INVALID_INDEX if a set bit cannot be found.
109 util_bitmask_get_next_index(struct util_bitmask
*bm
,
117 #endif /* U_HANDLE_BITMASK_H_ */