mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 02:33:03 +00:00
style: modernize lib/abitset.c
This commit is contained in:
159
lib/abitset.c
159
lib/abitset.c
@@ -36,10 +36,10 @@ static bitset_bindex
|
|||||||
abitset_resize (bitset src, bitset_bindex size)
|
abitset_resize (bitset src, bitset_bindex size)
|
||||||
{
|
{
|
||||||
/* These bitsets have a fixed size. */
|
/* These bitsets have a fixed size. */
|
||||||
if (BITSET_SIZE_ (src) != size)
|
if (BITSET_SIZE_ (src) != size)
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find list of up to NUM bits set in BSET starting from and including
|
/* Find list of up to NUM bits set in BSET starting from and including
|
||||||
@@ -49,19 +49,14 @@ static bitset_bindex
|
|||||||
abitset_small_list (bitset src, bitset_bindex *list,
|
abitset_small_list (bitset src, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
bitset_word word = ABITSET_WORDS (src)[0];
|
||||||
bitset_bindex count;
|
|
||||||
bitset_windex size;
|
|
||||||
bitset_word word;
|
|
||||||
|
|
||||||
word = ABITSET_WORDS (src)[0];
|
|
||||||
|
|
||||||
/* Short circuit common case. */
|
/* Short circuit common case. */
|
||||||
if (!word)
|
if (!word)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
size = BITSET_SIZE_ (src);
|
bitset_windex size = BITSET_SIZE_ (src);
|
||||||
bitno = *next;
|
bitset_bindex bitno = *next;
|
||||||
if (bitno >= size)
|
if (bitno >= size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -70,6 +65,7 @@ abitset_small_list (bitset src, bitset_bindex *list,
|
|||||||
/* If num is 1, we could speed things up with a binary search
|
/* If num is 1, we could speed things up with a binary search
|
||||||
of the word of interest. */
|
of the word of interest. */
|
||||||
|
|
||||||
|
bitset_bindex count;
|
||||||
if (num >= BITSET_WORD_BITS)
|
if (num >= BITSET_WORD_BITS)
|
||||||
{
|
{
|
||||||
for (count = 0; word; bitno++)
|
for (count = 0; word; bitno++)
|
||||||
@@ -142,16 +138,10 @@ static bitset_bindex
|
|||||||
abitset_list_reverse (bitset src, bitset_bindex *list,
|
abitset_list_reverse (bitset src, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
|
||||||
bitset_bindex rbitno;
|
|
||||||
bitset_bindex count;
|
|
||||||
bitset_windex windex;
|
|
||||||
unsigned bitcnt;
|
|
||||||
bitset_bindex bitoff;
|
|
||||||
bitset_word *srcp = ABITSET_WORDS (src);
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
bitset_bindex n_bits = BITSET_SIZE_ (src);
|
bitset_bindex n_bits = BITSET_SIZE_ (src);
|
||||||
|
|
||||||
rbitno = *next;
|
bitset_bindex rbitno = *next;
|
||||||
|
|
||||||
/* If num is 1, we could speed things up with a binary search
|
/* If num is 1, we could speed things up with a binary search
|
||||||
of the word of interest. */
|
of the word of interest. */
|
||||||
@@ -159,19 +149,17 @@ abitset_list_reverse (bitset src, bitset_bindex *list,
|
|||||||
if (rbitno >= n_bits)
|
if (rbitno >= n_bits)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
count = 0;
|
bitset_bindex count = 0;
|
||||||
|
|
||||||
bitno = n_bits - (rbitno + 1);
|
bitset_bindex bitno = n_bits - (rbitno + 1);
|
||||||
|
|
||||||
windex = bitno / BITSET_WORD_BITS;
|
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||||
bitcnt = bitno % BITSET_WORD_BITS;
|
unsigned bitcnt = bitno % BITSET_WORD_BITS;
|
||||||
bitoff = windex * BITSET_WORD_BITS;
|
bitset_bindex bitoff = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bitset_word word;
|
bitset_word word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||||
|
|
||||||
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
|
||||||
for (; word; bitcnt--)
|
for (; word; bitcnt--)
|
||||||
{
|
{
|
||||||
if (word & BITSET_MSB)
|
if (word & BITSET_MSB)
|
||||||
@@ -196,23 +184,21 @@ abitset_list_reverse (bitset src, bitset_bindex *list,
|
|||||||
|
|
||||||
|
|
||||||
/* Find list of up to NUM bits set in BSET starting from and including
|
/* Find list of up to NUM bits set in BSET starting from and including
|
||||||
*NEXT and store in array LIST. Return with actual number of bits
|
*NEXT and store in array LIST. Return with actual number of bits
|
||||||
found and with *NEXT indicating where search stopped. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
abitset_list (bitset src, bitset_bindex *list,
|
abitset_list (bitset src, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
|
||||||
bitset_bindex count;
|
|
||||||
bitset_windex windex;
|
bitset_windex windex;
|
||||||
bitset_bindex bitoff;
|
bitset_bindex bitoff;
|
||||||
bitset_windex size = src->b.csize;
|
bitset_windex size = src->b.csize;
|
||||||
bitset_word *srcp = ABITSET_WORDS (src);
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
bitset_word word;
|
bitset_word word;
|
||||||
|
|
||||||
bitno = *next;
|
bitset_bindex bitno = *next;
|
||||||
|
|
||||||
count = 0;
|
bitset_bindex count = 0;
|
||||||
if (!bitno)
|
if (!bitno)
|
||||||
{
|
{
|
||||||
/* Many bitsets are zero, so make this common case fast. */
|
/* Many bitsets are zero, so make this common case fast. */
|
||||||
@@ -302,9 +288,7 @@ abitset_list (bitset src, bitset_bindex *list,
|
|||||||
static inline void
|
static inline void
|
||||||
abitset_unused_clear (bitset dst)
|
abitset_unused_clear (bitset dst)
|
||||||
{
|
{
|
||||||
unsigned last_bit;
|
unsigned last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
|
||||||
|
|
||||||
last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
|
|
||||||
if (last_bit)
|
if (last_bit)
|
||||||
ABITSET_WORDS (dst)[dst->b.csize - 1] &=
|
ABITSET_WORDS (dst)[dst->b.csize - 1] &=
|
||||||
((bitset_word) 1 << last_bit) - 1;
|
((bitset_word) 1 << last_bit) - 1;
|
||||||
@@ -315,9 +299,7 @@ static void
|
|||||||
abitset_ones (bitset dst)
|
abitset_ones (bitset dst)
|
||||||
{
|
{
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
size_t bytes;
|
size_t bytes = sizeof (bitset_word) * dst->b.csize;
|
||||||
|
|
||||||
bytes = sizeof (bitset_word) * dst->b.csize;
|
|
||||||
|
|
||||||
memset (dstp, -1, bytes);
|
memset (dstp, -1, bytes);
|
||||||
abitset_unused_clear (dst);
|
abitset_unused_clear (dst);
|
||||||
@@ -328,9 +310,7 @@ static void
|
|||||||
abitset_zero (bitset dst)
|
abitset_zero (bitset dst)
|
||||||
{
|
{
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
size_t bytes;
|
size_t bytes = sizeof (bitset_word) * dst->b.csize;
|
||||||
|
|
||||||
bytes = sizeof (bitset_word) * dst->b.csize;
|
|
||||||
|
|
||||||
memset (dstp, 0, bytes);
|
memset (dstp, 0, bytes);
|
||||||
}
|
}
|
||||||
@@ -339,10 +319,9 @@ abitset_zero (bitset dst)
|
|||||||
static bool
|
static bool
|
||||||
abitset_empty_p (bitset dst)
|
abitset_empty_p (bitset dst)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
|
||||||
for (i = 0; i < dst->b.csize; i++)
|
for (bitset_windex i = 0; i < dst->b.csize; i++)
|
||||||
if (dstp[i])
|
if (dstp[i])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -366,13 +345,12 @@ abitset_copy1 (bitset dst, bitset src)
|
|||||||
static void
|
static void
|
||||||
abitset_not (bitset dst, bitset src)
|
abitset_not (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *srcp = ABITSET_WORDS (src);
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = ~(*srcp++);
|
*dstp++ = ~(*srcp++);
|
||||||
abitset_unused_clear (dst);
|
abitset_unused_clear (dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,14 +358,13 @@ abitset_not (bitset dst, bitset src)
|
|||||||
static bool
|
static bool
|
||||||
abitset_equal_p (bitset dst, bitset src)
|
abitset_equal_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *srcp = ABITSET_WORDS (src);
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
if (*srcp++ != *dstp++)
|
if (*srcp++ != *dstp++)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,14 +372,13 @@ abitset_equal_p (bitset dst, bitset src)
|
|||||||
static bool
|
static bool
|
||||||
abitset_subset_p (bitset dst, bitset src)
|
abitset_subset_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *srcp = ABITSET_WORDS (src);
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++, dstp++, srcp++)
|
for (bitset_windex i = 0; i < size; i++, dstp++, srcp++)
|
||||||
if (*dstp != (*srcp | *dstp))
|
if (*dstp != (*srcp | *dstp))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,14 +386,13 @@ abitset_subset_p (bitset dst, bitset src)
|
|||||||
static bool
|
static bool
|
||||||
abitset_disjoint_p (bitset dst, bitset src)
|
abitset_disjoint_p (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *srcp = ABITSET_WORDS (src);
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
if (*srcp++ & *dstp++)
|
if (*srcp++ & *dstp++)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -426,28 +401,26 @@ abitset_disjoint_p (bitset dst, bitset src)
|
|||||||
static void
|
static void
|
||||||
abitset_and (bitset dst, bitset src1, bitset src2)
|
abitset_and (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = *src1p++ & *src2p++;
|
*dstp++ = *src1p++ & *src2p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
abitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
abitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++, dstp++)
|
for (bitset_windex i = 0; i < size; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *src1p++ & *src2p++;
|
bitset_word tmp = *src1p++ & *src2p++;
|
||||||
|
|
||||||
@@ -464,28 +437,26 @@ abitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
static void
|
static void
|
||||||
abitset_andn (bitset dst, bitset src1, bitset src2)
|
abitset_andn (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = *src1p++ & ~(*src2p++);
|
*dstp++ = *src1p++ & ~(*src2p++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++, dstp++)
|
for (bitset_windex i = 0; i < size; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *src1p++ & ~(*src2p++);
|
bitset_word tmp = *src1p++ & ~(*src2p++);
|
||||||
|
|
||||||
@@ -502,28 +473,26 @@ abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
static void
|
static void
|
||||||
abitset_or (bitset dst, bitset src1, bitset src2)
|
abitset_or (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = *src1p++ | *src2p++;
|
*dstp++ = *src1p++ | *src2p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
abitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
abitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++, dstp++)
|
for (bitset_windex i = 0; i < size; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *src1p++ | *src2p++;
|
bitset_word tmp = *src1p++ | *src2p++;
|
||||||
|
|
||||||
@@ -540,13 +509,12 @@ abitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
static void
|
static void
|
||||||
abitset_xor (bitset dst, bitset src1, bitset src2)
|
abitset_xor (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = *src1p++ ^ *src2p++;
|
*dstp++ = *src1p++ ^ *src2p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -554,14 +522,13 @@ abitset_xor (bitset dst, bitset src1, bitset src2)
|
|||||||
static bool
|
static bool
|
||||||
abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++, dstp++)
|
for (bitset_windex i = 0; i < size; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *src1p++ ^ *src2p++;
|
bitset_word tmp = *src1p++ ^ *src2p++;
|
||||||
|
|
||||||
@@ -578,22 +545,20 @@ abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
static void
|
static void
|
||||||
abitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
abitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
|
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
@@ -601,7 +566,7 @@ abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++, dstp++)
|
for (bitset_windex i = 0; i < size; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
||||||
|
|
||||||
@@ -618,22 +583,20 @@ abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
static void
|
static void
|
||||||
abitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
abitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
|
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
@@ -641,7 +604,7 @@ abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++, dstp++)
|
for (bitset_windex i = 0; i < size; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||||
|
|
||||||
@@ -658,22 +621,20 @@ abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
static void
|
static void
|
||||||
abitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
abitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (bitset_windex i = 0; i < size; i++)
|
||||||
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
|
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
@@ -681,7 +642,7 @@ abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
bitset_windex size = dst->b.csize;
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
for (i = 0; i < size; i++, dstp++)
|
for (bitset_windex i = 0; i < size; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
||||||
|
|
||||||
@@ -699,9 +660,9 @@ static void
|
|||||||
abitset_copy (bitset dst, bitset src)
|
abitset_copy (bitset dst, bitset src)
|
||||||
{
|
{
|
||||||
if (BITSET_COMPATIBLE_ (dst, src))
|
if (BITSET_COMPATIBLE_ (dst, src))
|
||||||
abitset_copy1 (dst, src);
|
abitset_copy1 (dst, src);
|
||||||
else
|
else
|
||||||
bitset_copy_ (dst, src);
|
bitset_copy_ (dst, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -784,14 +745,12 @@ struct bitset_vtable abitset_vtable = {
|
|||||||
size_t
|
size_t
|
||||||
abitset_bytes (bitset_bindex n_bits)
|
abitset_bytes (bitset_bindex n_bits)
|
||||||
{
|
{
|
||||||
bitset_windex size;
|
|
||||||
size_t bytes;
|
|
||||||
size_t header_size = offsetof (union bitset_union, a.words);
|
size_t header_size = offsetof (union bitset_union, a.words);
|
||||||
struct bitset_align_struct { char a; union bitset_union b; };
|
struct bitset_align_struct { char a; union bitset_union b; };
|
||||||
size_t bitset_alignment = offsetof (struct bitset_align_struct, b);
|
size_t bitset_alignment = offsetof (struct bitset_align_struct, b);
|
||||||
|
|
||||||
size = ABITSET_N_WORDS (n_bits);
|
bitset_windex size = ABITSET_N_WORDS (n_bits);
|
||||||
bytes = header_size + size * sizeof (bitset_word);
|
size_t bytes = header_size + size * sizeof (bitset_word);
|
||||||
|
|
||||||
/* Align the size properly for a vector of abitset objects. */
|
/* Align the size properly for a vector of abitset objects. */
|
||||||
if (header_size % bitset_alignment != 0
|
if (header_size % bitset_alignment != 0
|
||||||
@@ -808,9 +767,7 @@ abitset_bytes (bitset_bindex n_bits)
|
|||||||
bitset
|
bitset
|
||||||
abitset_init (bitset bset, bitset_bindex n_bits)
|
abitset_init (bitset bset, bitset_bindex n_bits)
|
||||||
{
|
{
|
||||||
bitset_windex size;
|
bitset_windex size = ABITSET_N_WORDS (n_bits);
|
||||||
|
|
||||||
size = ABITSET_N_WORDS (n_bits);
|
|
||||||
BITSET_NBITS_ (bset) = n_bits;
|
BITSET_NBITS_ (bset) = n_bits;
|
||||||
|
|
||||||
/* Use optimized routines if bitset fits within a single word.
|
/* Use optimized routines if bitset fits within a single word.
|
||||||
|
|||||||
Reference in New Issue
Block a user