1cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Variable array bitsets. 2cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. 3cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). 4cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 5cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project This program is free software; you can redistribute it and/or modify 6cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project it under the terms of the GNU General Public License as published by 7cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project the Free Software Foundation; either version 2 of the License, or 8cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project (at your option) any later version. 9cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 10cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project This program is distributed in the hope that it will be useful, 11cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project but WITHOUT ANY WARRANTY; without even the implied warranty of 12cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project GNU General Public License for more details. 14cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 15cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project You should have received a copy of the GNU General Public License 16cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project along with this program; if not, write to the Free Software Foundation, 17cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 18cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 19cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#ifdef HAVE_CONFIG_H 20cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# include <config.h> 21cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#endif 22cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 23cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#include "vbitset.h" 24cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#include <stdlib.h> 25cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#include <string.h> 26cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 27cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* This file implements variable size bitsets stored as a variable 28cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project length array of words. Any unused bits in the last word must be 29cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project zero. 30cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 31cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project Note that binary or ternary operations assume that each bitset operand 32cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project has the same size. 33cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project*/ 34cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 35cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void vbitset_unused_clear (bitset); 36cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 37cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void vbitset_set (bitset, bitset_bindex); 38cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void vbitset_reset (bitset, bitset_bindex); 39cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bool vbitset_test (bitset, bitset_bindex); 40cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bitset_bindex vbitset_list (bitset, bitset_bindex *, 41cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex, bitset_bindex *); 42cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bitset_bindex vbitset_list_reverse (bitset, bitset_bindex *, 43cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex, bitset_bindex *); 44cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 45cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#define VBITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS) 46cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#define VBITSET_WORDS(X) ((X)->b.cdata) 47cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#define VBITSET_SIZE(X) ((X)->b.csize) 48cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#define VBITSET_ASIZE(X) ((X)->v.size) 49cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 50cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#undef min 51cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#undef max 52cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#define min(a, b) ((a) > (b) ? (b) : (a)) 53cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#define max(a, b) ((a) > (b) ? (a) : (b)) 54cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 55cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bitset_bindex 56cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_resize (bitset src, bitset_bindex n_bits) 57cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 58cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex oldsize; 59cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex newsize; 60cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 61cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (n_bits == BITSET_NBITS_ (src)) 62cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return n_bits; 63cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 64cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project oldsize = VBITSET_SIZE (src); 65cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project newsize = VBITSET_N_WORDS (n_bits); 66cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 67cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (oldsize < newsize) 68cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 69cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex size; 70cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 71cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project /* The bitset needs to grow. If we already have enough memory 72cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project allocated, then just zero what we need. */ 73cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (newsize > VBITSET_ASIZE (src)) 74cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 75cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project /* We need to allocate more memory. When oldsize is 76cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project non-zero this means that we are changing the size, so 77cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project grow the bitset 25% larger than requested to reduce 78cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project number of reallocations. */ 79cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 80cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (oldsize == 0) 81cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project size = newsize; 82cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project else 83cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project size = newsize + newsize / 4; 84cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 85cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project VBITSET_WORDS (src) 86cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project = realloc (VBITSET_WORDS (src), size * sizeof (bitset_word)); 87cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project VBITSET_ASIZE (src) = size; 88cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 89cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 90cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (VBITSET_WORDS (src) + oldsize, 0, 91cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project (newsize - oldsize) * sizeof (bitset_word)); 92cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project VBITSET_SIZE (src) = newsize; 93cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 94cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project else 95cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 96cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project /* The bitset needs to shrink. There's no point deallocating 97cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project the memory unless it is shrinking by a reasonable amount. */ 98cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if ((oldsize - newsize) >= oldsize / 2) 99cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 100cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project VBITSET_WORDS (src) 101cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project = realloc (VBITSET_WORDS (src), newsize * sizeof (bitset_word)); 102cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project VBITSET_ASIZE (src) = newsize; 103cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 104cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 105cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project /* Need to prune any excess bits. FIXME. */ 106cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 107cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project VBITSET_SIZE (src) = newsize; 108cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 109cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 110cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project BITSET_NBITS_ (src) = n_bits; 111cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return n_bits; 112cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 113cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 114cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 115cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Set bit BITNO in bitset DST. */ 116cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void 117cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_set (dst, bitno) 118cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset dst; 119cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex bitno; 120cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 121cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex windex = bitno / BITSET_WORD_BITS; 122cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 123cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project /* Perhaps we should abort. The user should explicitly call 124cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_resize since this will not catch the case when we set a 125cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bit larger than the current size but smaller than the allocated 126cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project size. */ 127cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, bitno); 128cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 129cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dst->b.cdata[windex - dst->b.cindex] |= 130cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project (bitset_word) 1 << (bitno % BITSET_WORD_BITS); 131cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 132cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 133cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 134cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Reset bit BITNO in bitset DST. */ 135cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void 136cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_reset (dst, bitno) 137cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset dst ATTRIBUTE_UNUSED; 138cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex bitno ATTRIBUTE_UNUSED; 139cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 140cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project /* We must be accessing outside the cache so the bit is 141cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project zero anyway. */ 142cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 143cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 144cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 145cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Test bit BITNO in bitset SRC. */ 146cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bool 147cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_test (src, bitno) 148cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset src ATTRIBUTE_UNUSED; 149cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex bitno ATTRIBUTE_UNUSED; 150cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 151cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project /* We must be accessing outside the cache so the bit is 152cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project zero anyway. */ 153cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 0; 154cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 155cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 156cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 157cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Find list of up to NUM bits set in BSET in reverse order, starting 158cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project from and including NEXT and store in array LIST. Return with 159cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project actual number of bits found and with *NEXT indicating where search 160cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project stopped. */ 161cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bitset_bindex 162cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_list_reverse (src, list, num, next) 163cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset src; 164cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex *list; 165cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex num; 166cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex *next; 167cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 168cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex bitno; 169cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex rbitno; 170cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex count; 171cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex windex; 172cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int bitcnt; 173cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex bitoff; 174cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *srcp = VBITSET_WORDS (src); 175cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex n_bits = BITSET_SIZE_ (src); 176cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 177cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project rbitno = *next; 178cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 179cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project /* If num is 1, we could speed things up with a binary search 180cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project of the word of interest. */ 181cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 182cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (rbitno >= n_bits) 183cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 0; 184cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 185cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project count = 0; 186cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 187cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitno = n_bits - (rbitno + 1); 188cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 189cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project windex = bitno / BITSET_WORD_BITS; 190cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitcnt = bitno % BITSET_WORD_BITS; 191cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitoff = windex * BITSET_WORD_BITS; 192cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 193cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project do 194cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 195cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word word; 196cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 197cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt); 198cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (; word; bitcnt--) 199cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 200cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (word & BITSET_MSB) 201cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 202cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project list[count++] = bitoff + bitcnt; 203cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (count >= num) 204cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 205cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *next = n_bits - (bitoff + bitcnt); 206cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return count; 207cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 208cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 209cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project word <<= 1; 210cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 211cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitoff -= BITSET_WORD_BITS; 212cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitcnt = BITSET_WORD_BITS - 1; 213cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 214cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project while (windex--); 215cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 216cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *next = n_bits - (bitoff + 1); 217cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return count; 218cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 219cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 220cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 221cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Find list of up to NUM bits set in BSET starting from and including 222cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *NEXT and store in array LIST. Return with actual number of bits 223cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project found and with *NEXT indicating where search stopped. */ 224cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bitset_bindex 225cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_list (src, list, num, next) 226cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset src; 227cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex *list; 228cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex num; 229cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex *next; 230cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 231cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex bitno; 232cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex count; 233cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex windex; 234cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex bitoff; 235cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex size = VBITSET_SIZE (src); 236cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *srcp = VBITSET_WORDS (src); 237cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word word; 238cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 239cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitno = *next; 240cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 241cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project count = 0; 242cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (!bitno) 243cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 244cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project /* Many bitsets are zero, so make this common case fast. */ 245cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (windex = 0; windex < size && !srcp[windex]; windex++) 246cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project continue; 247cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (windex >= size) 248cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 0; 249cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 250cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project /* If num is 1, we could speed things up with a binary search 251cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project of the current word. */ 252cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 253cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitoff = windex * BITSET_WORD_BITS; 254cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 255cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project else 256cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 257cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (bitno >= BITSET_SIZE_ (src)) 258cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 0; 259cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 260cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project windex = bitno / BITSET_WORD_BITS; 261cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitno = bitno % BITSET_WORD_BITS; 262cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 263cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (bitno) 264cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 265cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project /* Handle the case where we start within a word. 266cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project Most often, this is executed with large bitsets 267cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project with many set bits where we filled the array 268cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project on the previous call to this function. */ 269cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 270cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitoff = windex * BITSET_WORD_BITS; 271cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project word = srcp[windex] >> bitno; 272cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (bitno = bitoff + bitno; word; bitno++) 273cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 274cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (word & 1) 275cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 276cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project list[count++] = bitno; 277cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (count >= num) 278cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 279cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *next = bitno + 1; 280cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return count; 281cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 282cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 283cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project word >>= 1; 284cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 285cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project windex++; 286cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 287cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitoff = windex * BITSET_WORD_BITS; 288cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 289cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 290cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (; windex < size; windex++, bitoff += BITSET_WORD_BITS) 291cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 292cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (!(word = srcp[windex])) 293cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project continue; 294cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 295cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if ((count + BITSET_WORD_BITS) < num) 296cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 297cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (bitno = bitoff; word; bitno++) 298cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 299cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (word & 1) 300cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project list[count++] = bitno; 301cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project word >>= 1; 302cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 303cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 304cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project else 305cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 306cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (bitno = bitoff; word; bitno++) 307cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 308cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (word & 1) 309cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 310cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project list[count++] = bitno; 311cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (count >= num) 312cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 313cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *next = bitno + 1; 314cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return count; 315cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 316cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 317cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project word >>= 1; 318cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 319cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 320cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 321cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 322cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *next = bitoff; 323cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return count; 324cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 325cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 326cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 327cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Ensure that any unused bits within the last word are clear. */ 328cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic inline void 329cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_unused_clear (dst) 330cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset dst; 331cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 332cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int last_bit; 333cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 334cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS; 335cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (last_bit) 336cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project VBITSET_WORDS (dst)[VBITSET_SIZE (dst) - 1] &= 337cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ((bitset_word) 1 << last_bit) - 1; 338cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 339cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 340cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 341cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void 342cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_ones (bitset dst) 343cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 344cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp = VBITSET_WORDS (dst); 345cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int bytes; 346cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 347cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bytes = sizeof (bitset_word) * VBITSET_SIZE (dst); 348cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 349cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (dstp, -1, bytes); 350cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_unused_clear (dst); 351cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 352cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 353cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 354cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void 355cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_zero (bitset dst) 356cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 357cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp = VBITSET_WORDS (dst); 358cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int bytes; 359cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 360cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bytes = sizeof (bitset_word) * VBITSET_SIZE (dst); 361cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 362cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (dstp, 0, bytes); 363cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 364cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 365cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 366cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bool 367cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_empty_p (bitset dst) 368cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 369cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 370cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp = VBITSET_WORDS (dst); 371cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 372cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < VBITSET_SIZE (dst); i++) 373cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (dstp[i]) 374cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 0; 375cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 376cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 1; 377cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 378cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 379cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 380cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void 381cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_copy1 (bitset dst, bitset src) 382cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 383cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *srcp; 384cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 385cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize; 386cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex dsize; 387cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 388cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (src == dst) 389cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return; 390cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 391cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, BITSET_SIZE_ (src)); 392cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 393cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project srcp = VBITSET_WORDS (src); 394cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 395cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize = VBITSET_SIZE (src); 396cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dsize = VBITSET_SIZE (dst); 397cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 398cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memcpy (dstp, srcp, sizeof (bitset_word) * ssize); 399cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 400cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (dstp + sizeof (bitset_word) * ssize, 0, 401cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project sizeof (bitset_word) * (dsize - ssize)); 402cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 403cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 404cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 405cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void 406cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_not (bitset dst, bitset src) 407cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 408cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 409cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *srcp; 410cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 411cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize; 412cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex dsize; 413cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 414cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, BITSET_SIZE_ (src)); 415cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 416cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project srcp = VBITSET_WORDS (src); 417cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 418cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize = VBITSET_SIZE (src); 419cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dsize = VBITSET_SIZE (dst); 420cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 421cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < ssize; i++) 422cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp++ = ~(*srcp++); 423cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 424cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_unused_clear (dst); 425cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (dstp + sizeof (bitset_word) * ssize, 0, 426cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project sizeof (bitset_word) * (dsize - ssize)); 427cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 428cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 429cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 430cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bool 431cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_equal_p (bitset dst, bitset src) 432cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 433cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 434cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *srcp = VBITSET_WORDS (src); 435cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp = VBITSET_WORDS (dst); 436cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize = VBITSET_SIZE (src); 437cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex dsize = VBITSET_SIZE (dst); 438cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 439cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < min (ssize, dsize); i++) 440cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*srcp++ != *dstp++) 441cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 0; 442cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 443cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (ssize > dsize) 444cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 445cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (; i < ssize; i++) 446cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*srcp++) 447cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 0; 448cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 449cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project else 450cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 451cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (; i < dsize; i++) 452cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*dstp++) 453cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 0; 454cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 455cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 456cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 1; 457cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 458cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 459cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 460cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bool 461cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_subset_p (bitset dst, bitset src) 462cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 463cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 464cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *srcp = VBITSET_WORDS (src); 465cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp = VBITSET_WORDS (dst); 466cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize = VBITSET_SIZE (src); 467cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex dsize = VBITSET_SIZE (dst); 468cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 469cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++) 470cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*dstp != (*srcp | *dstp)) 471cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 0; 472cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 473cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (ssize > dsize) 474cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 475cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (; i < ssize; i++) 476cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*srcp++) 477cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 0; 478cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 479cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 480cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 1; 481cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 482cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 483cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 484cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bool 485cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_disjoint_p (bitset dst, bitset src) 486cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 487cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 488cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *srcp = VBITSET_WORDS (src); 489cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp = VBITSET_WORDS (dst); 490cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize = VBITSET_SIZE (src); 491cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex dsize = VBITSET_SIZE (dst); 492cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 493cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < min (ssize, dsize); i++) 494cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*srcp++ & *dstp++) 495cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 0; 496cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 497cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return 1; 498cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 499cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 500cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 501cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void 502cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_and (bitset dst, bitset src1, bitset src2) 503cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 504cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 505cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src1p; 506cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src2p; 507cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 508cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize1; 509cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize2; 510cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex dsize; 511cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 512cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2))); 513cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 514cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dsize = VBITSET_SIZE (dst); 515cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize1 = VBITSET_SIZE (src1); 516cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize2 = VBITSET_SIZE (src2); 517cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 518cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = VBITSET_WORDS (src1); 519cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src2p = VBITSET_WORDS (src2); 520cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 521cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < min (ssize1, ssize2); i++) 522cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp++ = *src1p++ & *src2p++; 523cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 524cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (dstp, 0, sizeof (bitset_word) * (dsize - min (ssize1, ssize2))); 525cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 526cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 527cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 528cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bool 529cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_and_cmp (bitset dst, bitset src1, bitset src2) 530cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 531cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 532cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project int changed = 0; 533cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src1p; 534cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src2p; 535cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 536cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize1; 537cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize2; 538cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex dsize; 539cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 540cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2))); 541cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 542cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dsize = VBITSET_SIZE (dst); 543cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize1 = VBITSET_SIZE (src1); 544cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize2 = VBITSET_SIZE (src2); 545cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 546cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = VBITSET_WORDS (src1); 547cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src2p = VBITSET_WORDS (src2); 548cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 549cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < min (ssize1, ssize2); i++, dstp++) 550cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 551cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word tmp = *src1p++ & *src2p++; 552cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 553cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*dstp != tmp) 554cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 555cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project changed = 1; 556cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp = tmp; 557cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 558cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 559cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 560cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (ssize2 > ssize1) 561cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 562cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = src2p; 563cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize1 = ssize2; 564cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 565cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 566cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (; i < ssize1; i++, dstp++) 567cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 568cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*dstp != 0) 569cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 570cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project changed = 1; 571cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp = 0; 572cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 573cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 574cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 575cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1)); 576cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 577cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return changed; 578cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 579cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 580cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 581cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void 582cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_andn (bitset dst, bitset src1, bitset src2) 583cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 584cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 585cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src1p; 586cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src2p; 587cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 588cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize1; 589cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize2; 590cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex dsize; 591cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 592cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2))); 593cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 594cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dsize = VBITSET_SIZE (dst); 595cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize1 = VBITSET_SIZE (src1); 596cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize2 = VBITSET_SIZE (src2); 597cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 598cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = VBITSET_WORDS (src1); 599cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src2p = VBITSET_WORDS (src2); 600cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 601cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < min (ssize1, ssize2); i++) 602cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp++ = *src1p++ & ~(*src2p++); 603cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 604cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (ssize2 > ssize1) 605cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 606cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (; i < ssize2; i++) 607cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp++ = 0; 608cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 609cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2)); 610cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 611cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project else 612cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 613cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (; i < ssize1; i++) 614cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp++ = *src1p++; 615cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 616cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1)); 617cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 618cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 619cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 620cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 621cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bool 622cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_andn_cmp (bitset dst, bitset src1, bitset src2) 623cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 624cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 625cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project int changed = 0; 626cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src1p; 627cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src2p; 628cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 629cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize1; 630cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize2; 631cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex dsize; 632cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 633cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2))); 634cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 635cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dsize = VBITSET_SIZE (dst); 636cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize1 = VBITSET_SIZE (src1); 637cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize2 = VBITSET_SIZE (src2); 638cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 639cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = VBITSET_WORDS (src1); 640cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src2p = VBITSET_WORDS (src2); 641cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 642cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < min (ssize1, ssize2); i++, dstp++) 643cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 644cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word tmp = *src1p++ & ~(*src2p++); 645cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 646cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*dstp != tmp) 647cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 648cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project changed = 1; 649cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp = tmp; 650cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 651cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 652cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 653cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (ssize2 > ssize1) 654cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 655cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (; i < ssize2; i++, dstp++) 656cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 657cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*dstp != 0) 658cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 659cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project changed = 1; 660cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp = 0; 661cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 662cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 663cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 664cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2)); 665cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 666cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project else 667cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 668cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (; i < ssize1; i++, dstp++) 669cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 670cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word tmp = *src1p++; 671cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 672cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*dstp != tmp) 673cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 674cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project changed = 1; 675cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp = tmp; 676cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 677cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 678cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 679cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1)); 680cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 681cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 682cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return changed; 683cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 684cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 685cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 686cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void 687cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_or (bitset dst, bitset src1, bitset src2) 688cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 689cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 690cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src1p; 691cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src2p; 692cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 693cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize1; 694cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize2; 695cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex dsize; 696cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 697cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2))); 698cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 699cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dsize = VBITSET_SIZE (dst); 700cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize1 = VBITSET_SIZE (src1); 701cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize2 = VBITSET_SIZE (src2); 702cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 703cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = VBITSET_WORDS (src1); 704cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src2p = VBITSET_WORDS (src2); 705cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 706cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < min (ssize1, ssize2); i++) 707cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp++ = *src1p++ | *src2p++; 708cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 709cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (ssize2 > ssize1) 710cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 711cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = src2p; 712cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize1 = ssize2; 713cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 714cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 715cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (; i < ssize1; i++) 716cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp++ = *src1p++; 717cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 718cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1)); 719cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 720cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 721cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 722cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bool 723cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_or_cmp (bitset dst, bitset src1, bitset src2) 724cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 725cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 726cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project int changed = 0; 727cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src1p; 728cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src2p; 729cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 730cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize1; 731cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize2; 732cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex dsize; 733cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 734cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2))); 735cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 736cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dsize = VBITSET_SIZE (dst); 737cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize1 = VBITSET_SIZE (src1); 738cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize2 = VBITSET_SIZE (src2); 739cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 740cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = VBITSET_WORDS (src1); 741cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src2p = VBITSET_WORDS (src2); 742cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 743cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < min (ssize1, ssize2); i++, dstp++) 744cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 745cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word tmp = *src1p++ | *src2p++; 746cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 747cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*dstp != tmp) 748cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 749cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project changed = 1; 750cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp = tmp; 751cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 752cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 753cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 754cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (ssize2 > ssize1) 755cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 756cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = src2p; 757cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize1 = ssize2; 758cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 759cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 760cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (; i < ssize1; i++, dstp++) 761cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 762cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word tmp = *src1p++; 763cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 764cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*dstp != tmp) 765cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 766cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project changed = 1; 767cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp = tmp; 768cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 769cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 770cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 771cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1)); 772cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 773cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return changed; 774cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 775cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 776cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 777cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void 778cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_xor (bitset dst, bitset src1, bitset src2) 779cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 780cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 781cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src1p; 782cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src2p; 783cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 784cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize1; 785cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize2; 786cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex dsize; 787cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 788cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2))); 789cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 790cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dsize = VBITSET_SIZE (dst); 791cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize1 = VBITSET_SIZE (src1); 792cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize2 = VBITSET_SIZE (src2); 793cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 794cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = VBITSET_WORDS (src1); 795cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src2p = VBITSET_WORDS (src2); 796cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 797cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < min (ssize1, ssize2); i++) 798cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp++ = *src1p++ ^ *src2p++; 799cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 800cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (ssize2 > ssize1) 801cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 802cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = src2p; 803cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize1 = ssize2; 804cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 805cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 806cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (; i < ssize1; i++) 807cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp++ = *src1p++; 808cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 809cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1)); 810cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 811cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 812cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 813cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bool 814cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_xor_cmp (bitset dst, bitset src1, bitset src2) 815cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 816cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 817cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project int changed = 0; 818cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src1p; 819cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src2p; 820cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 821cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize1; 822cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex ssize2; 823cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex dsize; 824cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 825cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2))); 826cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 827cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dsize = VBITSET_SIZE (dst); 828cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize1 = VBITSET_SIZE (src1); 829cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize2 = VBITSET_SIZE (src2); 830cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 831cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = VBITSET_WORDS (src1); 832cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src2p = VBITSET_WORDS (src2); 833cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 834cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < min (ssize1, ssize2); i++, dstp++) 835cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 836cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word tmp = *src1p++ ^ *src2p++; 837cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 838cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*dstp != tmp) 839cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 840cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project changed = 1; 841cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp = tmp; 842cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 843cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 844cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 845cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (ssize2 > ssize1) 846cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 847cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = src2p; 848cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project ssize1 = ssize2; 849cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 850cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 851cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (; i < ssize1; i++, dstp++) 852cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 853cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word tmp = *src1p++; 854cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 855cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*dstp != tmp) 856cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 857cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project changed = 1; 858cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp = tmp; 859cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 860cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 861cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 862cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1)); 863cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 864cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return changed; 865cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 866cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 867cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 868cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* FIXME, these operations need fixing for different size 869cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitsets. */ 870cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 871cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void 872cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3) 873cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 874cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 875cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src1p; 876cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src2p; 877cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src3p; 878cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 879cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex size; 880cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 881cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2) 882cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project || BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3)) 883cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 884cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_and_or_ (dst, src1, src2, src3); 885cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return; 886cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 887cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 888cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, BITSET_NBITS_ (src1)); 889cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 890cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = VBITSET_WORDS (src1); 891cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src2p = VBITSET_WORDS (src2); 892cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src3p = VBITSET_WORDS (src3); 893cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 894cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project size = VBITSET_SIZE (dst); 895cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 896cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < size; i++) 897cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp++ = (*src1p++ & *src2p++) | *src3p++; 898cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 899cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 900cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 901cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bool 902cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3) 903cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 904cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 905cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project int changed = 0; 906cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src1p; 907cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src2p; 908cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src3p; 909cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 910cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex size; 911cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 912cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2) 913cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project || BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3)) 914cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return bitset_and_or_cmp_ (dst, src1, src2, src3); 915cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 916cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, BITSET_NBITS_ (src1)); 917cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 918cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = VBITSET_WORDS (src1); 919cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src2p = VBITSET_WORDS (src2); 920cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src3p = VBITSET_WORDS (src3); 921cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 922cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project size = VBITSET_SIZE (dst); 923cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 924cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < size; i++, dstp++) 925cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 926cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word tmp = (*src1p++ & *src2p++) | *src3p++; 927cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 928cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*dstp != tmp) 929cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 930cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project changed = 1; 931cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp = tmp; 932cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 933cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 934cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return changed; 935cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 936cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 937cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 938cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void 939cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3) 940cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 941cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 942cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src1p; 943cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src2p; 944cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src3p; 945cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 946cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex size; 947cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 948cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2) 949cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project || BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3)) 950cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 951cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_andn_or_ (dst, src1, src2, src3); 952cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return; 953cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 954cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 955cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, BITSET_NBITS_ (src1)); 956cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 957cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = VBITSET_WORDS (src1); 958cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src2p = VBITSET_WORDS (src2); 959cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src3p = VBITSET_WORDS (src3); 960cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 961cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project size = VBITSET_SIZE (dst); 962cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 963cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < size; i++) 964cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++; 965cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 966cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 967cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 968cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bool 969cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3) 970cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 971cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 972cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project int changed = 0; 973cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src1p; 974cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src2p; 975cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src3p; 976cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 977cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex size; 978cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 979cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2) 980cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project || BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3)) 981cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return bitset_andn_or_cmp_ (dst, src1, src2, src3); 982cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 983cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, BITSET_NBITS_ (src1)); 984cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 985cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = VBITSET_WORDS (src1); 986cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src2p = VBITSET_WORDS (src2); 987cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src3p = VBITSET_WORDS (src3); 988cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 989cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project size = VBITSET_SIZE (dst); 990cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 991cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < size; i++, dstp++) 992cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 993cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++; 994cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 995cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*dstp != tmp) 996cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 997cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project changed = 1; 998cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp = tmp; 999cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 1000cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 1001cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return changed; 1002cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 1003cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1004cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1005cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void 1006cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3) 1007cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 1008cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 1009cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src1p; 1010cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src2p; 1011cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src3p; 1012cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 1013cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex size; 1014cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1015cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2) 1016cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project || BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3)) 1017cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 1018cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_or_and_ (dst, src1, src2, src3); 1019cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return; 1020cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 1021cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1022cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, BITSET_NBITS_ (src1)); 1023cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1024cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = VBITSET_WORDS (src1); 1025cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src2p = VBITSET_WORDS (src2); 1026cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src3p = VBITSET_WORDS (src3); 1027cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 1028cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project size = VBITSET_SIZE (dst); 1029cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1030cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < size; i++) 1031cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp++ = (*src1p++ | *src2p++) & *src3p++; 1032cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 1033cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1034cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1035cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic bool 1036cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3) 1037cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 1038cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project unsigned int i; 1039cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project int changed = 0; 1040cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src1p; 1041cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src2p; 1042cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *src3p; 1043cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word *dstp; 1044cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_windex size; 1045cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1046cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2) 1047cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project || BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3)) 1048cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return bitset_or_and_cmp_ (dst, src1, src2, src3); 1049cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1050cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (dst, BITSET_NBITS_ (src1)); 1051cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1052cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src1p = VBITSET_WORDS (src1); 1053cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src2p = VBITSET_WORDS (src2); 1054cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project src3p = VBITSET_WORDS (src3); 1055cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project dstp = VBITSET_WORDS (dst); 1056cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project size = VBITSET_SIZE (dst); 1057cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1058cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for (i = 0; i < size; i++, dstp++) 1059cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 1060cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_word tmp = (*src1p++ | *src2p++) & *src3p++; 1061cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1062cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (*dstp != tmp) 1063cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project { 1064cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project changed = 1; 1065cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project *dstp = tmp; 1066cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 1067cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project } 1068cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return changed; 1069cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 1070cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1071cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1072cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstatic void 1073cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_copy (bitset dst, bitset src) 1074cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 1075cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if (BITSET_COMPATIBLE_ (dst, src)) 1076cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_copy1 (dst, src); 1077cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project else 1078cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_copy_ (dst, src); 1079cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 1080cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1081cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1082cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Vector of operations for multiple word bitsets. */ 1083cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstruct bitset_vtable vbitset_vtable = { 1084cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_set, 1085cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_reset, 1086cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_toggle_, 1087cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_test, 1088cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize, 1089cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_size_, 1090cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_count_, 1091cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_empty_p, 1092cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_ones, 1093cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_zero, 1094cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_copy, 1095cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_disjoint_p, 1096cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_equal_p, 1097cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_not, 1098cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_subset_p, 1099cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_and, 1100cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_and_cmp, 1101cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_andn, 1102cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_andn_cmp, 1103cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_or, 1104cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_or_cmp, 1105cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_xor, 1106cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_xor_cmp, 1107cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_and_or, 1108cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_and_or_cmp, 1109cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_andn_or, 1110cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_andn_or_cmp, 1111cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_or_and, 1112cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_or_and_cmp, 1113cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_list, 1114cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_list_reverse, 1115cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project NULL, 1116cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project BITSET_VARRAY 1117cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project}; 1118cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1119cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1120cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectsize_t 1121cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_bytes (n_bits) 1122cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex n_bits ATTRIBUTE_UNUSED; 1123cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 1124cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return sizeof (struct vbitset_struct); 1125cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 1126cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1127cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1128cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectbitset 1129cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectvbitset_init (bset, n_bits) 1130cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset bset; 1131cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bitset_bindex n_bits; 1132cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 1133cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bset->b.vtable = &vbitset_vtable; 1134cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1135cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project bset->b.cindex = 0; 1136cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1137cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project VBITSET_SIZE (bset) = 0; 1138cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project vbitset_resize (bset, n_bits); 1139cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project return bset; 1140cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 1141