PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/opengles/src/codegen/bitset.h

http://ftk.googlecode.com/
C++ Header | 82 lines | 31 code | 22 blank | 29 comment | 1 complexity | 9c9a00ad12f3d81ce5078b637df2aa19 MD5 | raw file
 1#ifndef CODEGEN_BITSET_H
 2#define CODEGEN_BITSET_H 1
 3
 4/****************************************************************************/
 5/*																			*/
 6/* Copyright (c) 2004, Hans-Martin Will. All rights reserved.				*/
 7/*																			*/
 8/* Redistribution and use in source and binary forms, with or without		*/
 9/* modification, are permitted provided that the following conditions are   */
10/* met:																		*/
11/*																			*/
12/* *  Redistributions of source code must retain the above copyright		*/
13/*    notice, this list of conditions and the following disclaimer.			*/
14/*																			*/
15/* *  Redistributions in binary form must reproduce the above copyright		*/
16/*    notice, this list of conditions and the following disclaimer in the   */
17/*    documentation and/or other materials provided with the distribution.  */
18/*																			*/
19/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS		*/
20/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT		*/
21/* LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A   */
22/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER */
23/* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */
24/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,		*/
25/* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR		*/
26/* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   */
27/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING		*/
28/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS		*/
29/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.				*/
30/*																			*/
31/****************************************************************************/
32
33#include "codegen.h"
34#include "heap.h"
35
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41
42#define CG_BITSET_BITS_PER_WORD 32
43
44
45typedef struct cg_bitset_t
46{
47	size_t		elements;
48	U32			bits[1];
49}
50cg_bitset_t;
51
52
53cg_bitset_t * cg_bitset_create(cg_heap_t * heap, size_t elements);
54
55
56void cg_bitset_assign(cg_bitset_t * target, cg_bitset_t * source);
57
58
59/* target = target U (source \ minus) */
60int cg_bitset_union_minus(cg_bitset_t * target, cg_bitset_t * source,
61						   cg_bitset_t * minus);
62
63int cg_bitset_union(cg_bitset_t * target, cg_bitset_t * source);
64
65int cg_bitset_intersects(const cg_bitset_t * first, const cg_bitset_t * second);
66
67#define CG_BITSET_TEST(bitset, element) \
68	(((bitset->bits)[(element) / CG_BITSET_BITS_PER_WORD] & \
69	  (1 << ((element) % CG_BITSET_BITS_PER_WORD))) != 0)
70		
71#define CG_BITSET_SET(bitset, element) \
72((bitset->bits)[(element) / CG_BITSET_BITS_PER_WORD] |= (1 << ((element) % CG_BITSET_BITS_PER_WORD)))
73
74#define CG_BITSET_CLEAR(bitset, element) \
75((bitset->bits)[(element) / CG_BITSET_BITS_PER_WORD] &= ~(1 << ((element) % CG_BITSET_BITS_PER_WORD)))
76
77
78#ifdef __cplusplus
79}
80#endif
81
82#endif //ndef CODEGEN_BITSET_H