Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenbitset.h
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 6.5 00004 * 00005 * Copyright (C) 2006 Brian Paul All Rights Reserved. 00006 * 00007 * Permission is hereby granted, free of charge, to any person obtaining a 00008 * copy of this software and associated documentation files (the "Software"), 00009 * to deal in the Software without restriction, including without limitation 00010 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00011 * and/or sell copies of the Software, and to permit persons to whom the 00012 * Software is furnished to do so, subject to the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included 00015 * in all copies or substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00018 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00019 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00020 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00021 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00022 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00023 */ 00024 00031 /**************************************************************************** 00032 * generic bitset implementation 00033 */ 00034 00035 #define BITSET_WORD GLuint 00036 #define BITSET_WORDBITS (sizeof (BITSET_WORD) * 8) 00037 00038 /* bitset declarations 00039 */ 00040 #define BITSET_DECLARE(name, size) \ 00041 BITSET_WORD name[((size) + BITSET_WORDBITS - 1) / BITSET_WORDBITS] 00042 00043 /* bitset operations 00044 */ 00045 #define BITSET_COPY(x, y) _mesa_memcpy( (x), (y), sizeof (x) ) 00046 #define BITSET_EQUAL(x, y) (_mesa_memcmp( (x), (y), sizeof (x) ) == 0) 00047 #define BITSET_ZERO(x) _mesa_memset( (x), 0, sizeof (x) ) 00048 #define BITSET_ONES(x) _mesa_memset( (x), 0xff, sizeof (x) ) 00049 00050 #define BITSET_BITWORD(b) ((b) / BITSET_WORDBITS) 00051 #define BITSET_BIT(b) (1 << ((b) % BITSET_WORDBITS)) 00052 00053 /* single bit operations 00054 */ 00055 #define BITSET_TEST(x, b) ((x)[BITSET_BITWORD(b)] & BITSET_BIT(b)) 00056 #define BITSET_SET(x, b) ((x)[BITSET_BITWORD(b)] |= BITSET_BIT(b)) 00057 #define BITSET_CLEAR(x, b) ((x)[BITSET_BITWORD(b)] &= ~BITSET_BIT(b)) 00058 00059 #define BITSET_MASK(b) ((b) == BITSET_WORDBITS ? ~0 : BITSET_BIT(b) - 1) 00060 #define BITSET_RANGE(b, e) (BITSET_MASK((e) + 1) & ~BITSET_MASK(b)) 00061 00062 /* bit range operations 00063 */ 00064 #define BITSET_TEST_RANGE(x, b, e) \ 00065 (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ 00066 ((x)[BITSET_BITWORD(b)] & BITSET_RANGE(b, e)) : \ 00067 (assert (!"BITSET_TEST_RANGE: bit range crosses word boundary"), 0)) 00068 #define BITSET_SET_RANGE(x, b, e) \ 00069 (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ 00070 ((x)[BITSET_BITWORD(b)] |= BITSET_RANGE(b, e)) : \ 00071 (assert (!"BITSET_SET_RANGE: bit range crosses word boundary"), 0)) 00072 #define BITSET_CLEAR_RANGE(x, b, e) \ 00073 (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ 00074 ((x)[BITSET_BITWORD(b)] &= ~BITSET_RANGE(b, e)) : \ 00075 (assert (!"BITSET_CLEAR_RANGE: bit range crosses word boundary"), 0)) 00076 00077 /**************************************************************************** 00078 * 64-bit bitset implementation 00079 */ 00080 00081 #define BITSET64_WORD GLuint 00082 #define BITSET64_WORDBITS (sizeof (BITSET64_WORD) * 8) 00083 00084 /* bitset declarations 00085 */ 00086 #define BITSET64_DECLARE(name, size) \ 00087 GLuint name[2] 00088 00089 /* bitset operations 00090 */ 00091 #define BITSET64_COPY(x, y) do { (x)[0] = (y)[0]; (x)[1] = (y)[1]; } while (0) 00092 #define BITSET64_EQUAL(x, y) ( (x)[0] == (y)[0] && (x)[1] == (y)[1] ) 00093 #define BITSET64_ZERO(x) do { (x)[0] = 0; (x)[1] = 0; } while (0) 00094 #define BITSET64_ONES(x) do { (x)[0] = 0xFF; (x)[1] = 0xFF; } while (0) 00095 00096 #define BITSET64_BITWORD(b) ((b) / BITSET64_WORDBITS) 00097 #define BITSET64_BIT(b) (1 << ((b) % BITSET64_WORDBITS)) 00098 00099 /* single bit operations 00100 */ 00101 #define BITSET64_TEST(x, b) ((x)[BITSET64_BITWORD(b)] & BITSET64_BIT(b)) 00102 #define BITSET64_SET(x, b) ((x)[BITSET64_BITWORD(b)] |= BITSET64_BIT(b)) 00103 #define BITSET64_CLEAR(x, b) ((x)[BITSET64_BITWORD(b)] &= ~BITSET64_BIT(b)) 00104 00105 #define BITSET64_MASK(b) ((b) == BITSET64_WORDBITS ? ~0 : BITSET64_BIT(b) - 1) 00106 #define BITSET64_RANGE(b, e) (BITSET64_MASK((e) + 1) & ~BITSET64_MASK(b)) 00107 00108 /* bit range operations 00109 */ 00110 #define BITSET64_TEST_RANGE(x, b, e) \ 00111 (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ 00112 ((x)[BITSET64_BITWORD(b)] & BITSET64_RANGE(b, e)) : \ 00113 (assert (!"BITSET64_TEST_RANGE: bit range crosses word boundary"), 0)) 00114 #define BITSET64_SET_RANGE(x, b, e) \ 00115 (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ 00116 ((x)[BITSET64_BITWORD(b)] |= BITSET64_RANGE(b, e)) : \ 00117 (assert (!"BITSET64_SET_RANGE: bit range crosses word boundary"), 0)) 00118 #define BITSET64_CLEAR_RANGE(x, b, e) \ 00119 (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ 00120 ((x)[BITSET64_BITWORD(b)] &= ~BITSET64_RANGE(b, e)) : \ 00121 (assert (!"BITSET64_CLEAR_RANGE: bit range crosses word boundary"), 0)) 00122 Generated on Fri May 25 2012 04:18:16 for ReactOS by
1.7.6.1
|