revert 213 commits (to 56092) from the last month. 10 still need work to resolve...
[AROS.git] / workbench / libs / mesa / src / gallium / auxiliary / util / u_bitmask.h
blob98b85ddecd510be014f7ad080276870d41e80756
1 /**************************************************************************
2 *
3 * Copyright 2009 VMware, Inc.
4 * All Rights Reserved.
5 *
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
16 * of the Software.
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 **************************************************************************/
28 /**
29 * @file
30 * Generic bitmask.
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"
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
47 #define UTIL_BITMASK_INVALID_INDEX (~0U)
50 /**
51 * Abstract data type to represent arbitrary set of bits.
53 struct util_bitmask;
56 struct util_bitmask *
57 util_bitmask_create(void);
60 /**
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.
68 unsigned
69 util_bitmask_add(struct util_bitmask *bm);
71 /**
72 * Set a bit.
74 * Returns the input index on success, or UTIL_BITMASK_INVALID_INDEX on out of
75 * memory growing the bitmask.
77 unsigned
78 util_bitmask_set(struct util_bitmask *bm,
79 unsigned index);
81 void
82 util_bitmask_clear(struct util_bitmask *bm,
83 unsigned index);
85 boolean
86 util_bitmask_get(struct util_bitmask *bm,
87 unsigned index);
90 void
91 util_bitmask_destroy(struct util_bitmask *bm);
94 /**
95 * Search for the first set bit.
97 * Returns UTIL_BITMASK_INVALID_INDEX if a set bit cannot be found.
99 unsigned
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.
108 unsigned
109 util_bitmask_get_next_index(struct util_bitmask *bm,
110 unsigned index);
113 #ifdef __cplusplus
115 #endif
117 #endif /* U_HANDLE_BITMASK_H_ */