mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-26 20:53:04 +00:00
style: modernize lib/abitset.c
This commit is contained in:
119
lib/abitset.c
119
lib/abitset.c
@@ -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)
|
||||||
@@ -202,17 +190,15 @@ 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,12 +345,11 @@ 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,12 +358,11 @@ 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,12 +372,11 @@ 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,12 +386,11 @@ 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;
|
||||||
|
|
||||||
@@ -426,13 +401,12 @@ 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++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,14 +414,13 @@ abitset_and (bitset dst, bitset src1, bitset src2)
|
|||||||
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,13 +437,12 @@ 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++);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,14 +450,13 @@ abitset_andn (bitset dst, bitset src1, bitset src2)
|
|||||||
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,13 +473,12 @@ 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++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,14 +486,13 @@ abitset_or (bitset dst, bitset src1, bitset src2)
|
|||||||
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,14 +545,13 @@ 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++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,7 +559,6 @@ abitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
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,14 +583,13 @@ 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++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -633,7 +597,6 @@ abitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
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,14 +621,13 @@ 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++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,7 +635,6 @@ abitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
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++;
|
||||||
|
|
||||||
@@ -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