- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009 Free Software
- Foundation, Inc.
+
+ Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc.
+
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software: you can redistribute it and/or modify
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software: you can redistribute it and/or modify
static void vbitset_reset (bitset, bitset_bindex);
static bool vbitset_test (bitset, bitset_bindex);
static bitset_bindex vbitset_list (bitset, bitset_bindex *,
static void vbitset_reset (bitset, bitset_bindex);
static bool vbitset_test (bitset, bitset_bindex);
static bitset_bindex vbitset_list (bitset, bitset_bindex *,
#define VBITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
#define VBITSET_WORDS(X) ((X)->b.cdata)
#define VBITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
#define VBITSET_WORDS(X) ((X)->b.cdata)
- {
- /* We need to allocate more memory. When oldsize is
- non-zero this means that we are changing the size, so
- grow the bitset 25% larger than requested to reduce
- number of reallocations. */
-
- if (oldsize == 0)
- size = newsize;
- else
- size = newsize + newsize / 4;
-
- VBITSET_WORDS (src)
- = realloc (VBITSET_WORDS (src), size * sizeof (bitset_word));
- VBITSET_ASIZE (src) = size;
- }
+ {
+ /* We need to allocate more memory. When oldsize is
+ non-zero this means that we are changing the size, so
+ grow the bitset 25% larger than requested to reduce
+ number of reallocations. */
+
+ if (oldsize == 0)
+ size = newsize;
+ else
+ size = newsize + newsize / 4;
+
+ VBITSET_WORDS (src)
+ = realloc (VBITSET_WORDS (src), size * sizeof (bitset_word));
+ VBITSET_ASIZE (src) = size;
+ }
- {
- VBITSET_WORDS (src)
- = realloc (VBITSET_WORDS (src), newsize * sizeof (bitset_word));
- VBITSET_ASIZE (src) = newsize;
- }
+ {
+ VBITSET_WORDS (src)
+ = realloc (VBITSET_WORDS (src), newsize * sizeof (bitset_word));
+ VBITSET_ASIZE (src) = newsize;
+ }
{
/* Many bitsets are zero, so make this common case fast. */
for (windex = 0; windex < size && !srcp[windex]; windex++)
{
/* Many bitsets are zero, so make this common case fast. */
for (windex = 0; windex < size && !srcp[windex]; windex++)
- {
- /* Handle the case where we start within a word.
- Most often, this is executed with large bitsets
- with many set bits where we filled the array
- on the previous call to this function. */
-
- bitoff = windex * BITSET_WORD_BITS;
- word = srcp[windex] >> bitno;
- for (bitno = bitoff + bitno; word; bitno++)
- {
- if (word & 1)
- {
- list[count++] = bitno;
- if (count >= num)
- {
- *next = bitno + 1;
- return count;
- }
- }
- word >>= 1;
- }
- windex++;
- }
+ {
+ /* Handle the case where we start within a word.
+ Most often, this is executed with large bitsets
+ with many set bits where we filled the array
+ on the previous call to this function. */
+
+ bitoff = windex * BITSET_WORD_BITS;
+ word = srcp[windex] >> bitno;
+ for (bitno = bitoff + bitno; word; bitno++)
+ {
+ if (word & 1)
+ {
+ list[count++] = bitno;
+ if (count >= num)
+ {
+ *next = bitno + 1;
+ return count;
+ }
+ }
+ word >>= 1;
+ }
+ windex++;
+ }
bitoff = windex * BITSET_WORD_BITS;
}
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
{
if (!(word = srcp[windex]))
bitoff = windex * BITSET_WORD_BITS;
}
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
{
if (!(word = srcp[windex]))
memcpy (dstp, srcp, sizeof (bitset_word) * ssize);
memset (dstp + sizeof (bitset_word) * ssize, 0,
memcpy (dstp, srcp, sizeof (bitset_word) * ssize);
memset (dstp + sizeof (bitset_word) * ssize, 0,
vbitset_unused_clear (dst);
memset (dstp + sizeof (bitset_word) * ssize, 0,
vbitset_unused_clear (dst);
memset (dstp + sizeof (bitset_word) * ssize, 0,
for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++)
if (*dstp != (*srcp | *dstp))
for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++)
if (*dstp != (*srcp | *dstp))
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2));
}
else
{
for (; i < ssize1; i++, dstp++)
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2));
}
else
{
for (; i < ssize1; i++, dstp++)