14 |
|
|
15 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
16 |
along with this program; if not, write to the Free Software |
along with this program; if not, write to the Free Software |
17 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 |
*/ |
*/ |
19 |
|
|
20 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
37 |
Bitsets are commonly empty so we need to ensure that this special |
Bitsets are commonly empty so we need to ensure that this special |
38 |
case is fast. A zero bitset is indicated when cdata is 0. This is |
case is fast. A zero bitset is indicated when cdata is 0. This is |
39 |
conservative since cdata may be non zero and the bitset may still |
conservative since cdata may be non zero and the bitset may still |
40 |
be zero. |
be zero. |
41 |
|
|
42 |
The bitset cache can be disabled either by setting cindex to |
The bitset cache can be disabled either by setting cindex to |
43 |
BITSET_WINDEX_MAX or by setting csize to 0. Here |
BITSET_WINDEX_MAX or by setting csize to 0. Here |
44 |
we use the former approach since cindex needs to be updated whenever |
we use the former approach since cindex needs to be updated whenever |
45 |
cdata is changed. |
cdata is changed. |
46 |
*/ |
*/ |
47 |
|
|
48 |
|
|
83 |
|
|
84 |
enum ebitset_find_mode |
enum ebitset_find_mode |
85 |
{ EBITSET_FIND, EBITSET_CREATE, EBITSET_SUBST }; |
{ EBITSET_FIND, EBITSET_CREATE, EBITSET_SUBST }; |
|
typedef int enum_ebitset_find_mode; |
|
86 |
|
|
87 |
static ebitset_elt ebitset_zero_elts[1]; /* Elements of all zero bits. */ |
static ebitset_elt ebitset_zero_elts[1]; /* Elements of all zero bits. */ |
88 |
|
|
91 |
static int ebitset_obstack_init = 0; |
static int ebitset_obstack_init = 0; |
92 |
static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */ |
static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */ |
93 |
|
|
|
static void ebitset_elts_grow PARAMS ((bitset, bitset_windex)); |
|
|
static ebitset_elt *ebitset_elt_alloc PARAMS ((void)); |
|
|
static ebitset_elt *ebitset_elt_calloc PARAMS ((void)); |
|
|
static void ebitset_elt_add PARAMS ((bitset, ebitset_elt *, bitset_windex)); |
|
|
static void ebitset_elt_remove PARAMS ((bitset, bitset_windex)); |
|
|
static void ebitset_elt_free PARAMS ((ebitset_elt *)); |
|
|
static ebitset_elt *ebitset_elt_find PARAMS ((bitset, bitset_windex, |
|
|
enum_ebitset_find_mode)); |
|
|
static ebitset_elt *ebitset_elt_last PARAMS ((bitset)); |
|
|
static int ebitset_elt_zero_p PARAMS ((ebitset_elt *)); |
|
|
|
|
|
static bitset_windex ebitset_weed PARAMS ((bitset)); |
|
|
static void ebitset_zero PARAMS ((bitset)); |
|
|
static void ebitset_copy_ PARAMS ((bitset, bitset)); |
|
|
static int ebitset_copy_cmp PARAMS ((bitset, bitset)); |
|
|
static void ebitset_set PARAMS ((bitset, bitset_bindex)); |
|
|
static void ebitset_reset PARAMS ((bitset, bitset_bindex)); |
|
|
static int ebitset_test PARAMS ((bitset, bitset_bindex)); |
|
|
static bitset_bindex ebitset_size PARAMS ((bitset)); |
|
|
static int ebitset_disjoint_p PARAMS ((bitset, bitset)); |
|
|
static int ebitset_equal_p PARAMS ((bitset, bitset)); |
|
|
static void ebitset_not PARAMS ((bitset, bitset)); |
|
|
static int ebitset_subset_p PARAMS ((bitset, bitset)); |
|
|
static int ebitset_op3_cmp PARAMS ((bitset, bitset, bitset, enum_bitset_ops)); |
|
|
static void ebitset_and PARAMS ((bitset, bitset, bitset)); |
|
|
static int ebitset_and_cmp PARAMS ((bitset, bitset, bitset)); |
|
|
static void ebitset_andn PARAMS ((bitset, bitset, bitset)); |
|
|
static int ebitset_andn_cmp PARAMS ((bitset, bitset, bitset)); |
|
|
static void ebitset_or PARAMS ((bitset, bitset, bitset)); |
|
|
static int ebitset_or_cmp PARAMS ((bitset, bitset, bitset)); |
|
|
static void ebitset_xor PARAMS ((bitset, bitset, bitset)); |
|
|
static int ebitset_xor_cmp PARAMS ((bitset, bitset, bitset)); |
|
|
static void ebitset_copy PARAMS ((bitset, bitset)); |
|
|
static bitset_bindex ebitset_list PARAMS ((bitset, bitset_bindex *, |
|
|
bitset_bindex, bitset_bindex *)); |
|
|
static bitset_bindex ebitset_list_reverse |
|
|
PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *)); |
|
|
static void ebitset_ones PARAMS ((bitset)); |
|
|
static int ebitset_empty_p PARAMS ((bitset)); |
|
|
static void ebitset_free PARAMS ((bitset)); |
|
|
|
|
94 |
#define EBITSET_ELTS(BSET) ((BSET)->e.elts) |
#define EBITSET_ELTS(BSET) ((BSET)->e.elts) |
95 |
#define EBITSET_SIZE(BSET) ((BSET)->e.size) |
#define EBITSET_SIZE(BSET) ((BSET)->e.size) |
96 |
|
|
99 |
|
|
100 |
/* Disable bitset cache and mark BSET as being zero. */ |
/* Disable bitset cache and mark BSET as being zero. */ |
101 |
#define EBITSET_ZERO_SET(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX, \ |
#define EBITSET_ZERO_SET(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX, \ |
102 |
(BSET)->b.cdata = 0) |
(BSET)->b.cdata = 0) |
103 |
|
|
104 |
#define EBITSET_CACHE_DISABLE(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX) |
#define EBITSET_CACHE_DISABLE(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX) |
105 |
|
|
111 |
This is non-zero only if we know for sure that the bitset is zero. */ |
This is non-zero only if we know for sure that the bitset is zero. */ |
112 |
#define EBITSET_ZERO_P(BSET) ((BSET)->b.cdata == 0) |
#define EBITSET_ZERO_P(BSET) ((BSET)->b.cdata == 0) |
113 |
|
|
114 |
/* Enable cache to point to element with table index EINDEX. |
/* Enable cache to point to element with table index EINDEX. |
115 |
The element must exist. */ |
The element must exist. */ |
116 |
#define EBITSET_CACHE_SET(BSET, EINDEX) \ |
#define EBITSET_CACHE_SET(BSET, EINDEX) \ |
117 |
((BSET)->b.cindex = (EINDEX) * EBITSET_ELT_WORDS, \ |
((BSET)->b.cindex = (EINDEX) * EBITSET_ELT_WORDS, \ |
120 |
|
|
121 |
/* Grow the expandable table for BSET by SIZE elements. */ |
/* Grow the expandable table for BSET by SIZE elements. */ |
122 |
static void |
static void |
123 |
ebitset_elts_grow (bset, size) |
ebitset_elts_grow (bitset bset, bitset_windex size) |
|
bitset bset; |
|
|
bitset_windex size; |
|
124 |
{ |
{ |
125 |
bitset_windex oldsize; |
bitset_windex oldsize; |
126 |
bitset_windex newsize; |
bitset_windex newsize; |
141 |
|
|
142 |
/* Allocate a ebitset element. The bits are not cleared. */ |
/* Allocate a ebitset element. The bits are not cleared. */ |
143 |
static inline ebitset_elt * |
static inline ebitset_elt * |
144 |
ebitset_elt_alloc () |
ebitset_elt_alloc (void) |
145 |
{ |
{ |
146 |
ebitset_elt *elt; |
ebitset_elt *elt; |
147 |
|
|
196 |
|
|
197 |
/* Allocate a ebitset element. The bits are cleared. */ |
/* Allocate a ebitset element. The bits are cleared. */ |
198 |
static inline ebitset_elt * |
static inline ebitset_elt * |
199 |
ebitset_elt_calloc () |
ebitset_elt_calloc (void) |
200 |
{ |
{ |
201 |
ebitset_elt *elt; |
ebitset_elt *elt; |
202 |
|
|
207 |
|
|
208 |
|
|
209 |
static inline void |
static inline void |
210 |
ebitset_elt_free (elt) |
ebitset_elt_free (ebitset_elt *elt) |
|
ebitset_elt *elt; |
|
211 |
{ |
{ |
212 |
EBITSET_NEXT (elt) = ebitset_free_list; |
EBITSET_NEXT (elt) = ebitset_free_list; |
213 |
ebitset_free_list = elt; |
ebitset_free_list = elt; |
216 |
|
|
217 |
/* Remove element with index EINDEX from bitset BSET. */ |
/* Remove element with index EINDEX from bitset BSET. */ |
218 |
static inline void |
static inline void |
219 |
ebitset_elt_remove (bset, eindex) |
ebitset_elt_remove (bitset bset, bitset_windex eindex) |
|
bitset bset; |
|
|
bitset_windex eindex; |
|
220 |
{ |
{ |
221 |
ebitset_elts *elts; |
ebitset_elts *elts; |
222 |
ebitset_elt *elt; |
ebitset_elt *elt; |
232 |
|
|
233 |
/* Add ELT into elts at index EINDEX of bitset BSET. */ |
/* Add ELT into elts at index EINDEX of bitset BSET. */ |
234 |
static inline void |
static inline void |
235 |
ebitset_elt_add (bset, elt, eindex) |
ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex) |
|
bitset bset; |
|
|
ebitset_elt *elt; |
|
|
bitset_windex eindex; |
|
236 |
{ |
{ |
237 |
ebitset_elts *elts; |
ebitset_elts *elts; |
238 |
|
|
244 |
|
|
245 |
/* Return nonzero if all bits in an element are zero. */ |
/* Return nonzero if all bits in an element are zero. */ |
246 |
static inline int |
static inline int |
247 |
ebitset_elt_zero_p (elt) |
ebitset_elt_zero_p (ebitset_elt *elt) |
|
ebitset_elt *elt; |
|
248 |
{ |
{ |
249 |
int i; |
int i; |
250 |
|
|
257 |
|
|
258 |
|
|
259 |
static ebitset_elt * |
static ebitset_elt * |
260 |
ebitset_elt_find (bset, windex, mode) |
ebitset_elt_find (bitset bset, bitset_windex windex, |
261 |
bitset bset; |
enum ebitset_find_mode mode) |
|
bitset_windex windex; |
|
|
enum_ebitset_find_mode mode; |
|
262 |
{ |
{ |
263 |
ebitset_elt *elt; |
ebitset_elt *elt; |
264 |
bitset_windex size; |
bitset_windex size; |
323 |
|
|
324 |
|
|
325 |
static inline ebitset_elt * |
static inline ebitset_elt * |
326 |
ebitset_elt_last (bset) |
ebitset_elt_last (bitset bset) |
|
bitset bset; |
|
327 |
{ |
{ |
328 |
ebitset_elts *elts; |
ebitset_elts *elts; |
329 |
|
|
336 |
|
|
337 |
/* Weed out the zero elements from the elts. */ |
/* Weed out the zero elements from the elts. */ |
338 |
static inline bitset_windex |
static inline bitset_windex |
339 |
ebitset_weed (bset) |
ebitset_weed (bitset bset) |
|
bitset bset; |
|
340 |
{ |
{ |
341 |
ebitset_elts *elts; |
ebitset_elts *elts; |
342 |
bitset_windex j; |
bitset_windex j; |
366 |
count = j - count; |
count = j - count; |
367 |
if (!count) |
if (!count) |
368 |
{ |
{ |
369 |
/* All the bits are zero. We could shrink the elts. |
/* All the bits are zero. We could shrink the elts. |
370 |
For now just mark BSET as known to be zero. */ |
For now just mark BSET as known to be zero. */ |
371 |
EBITSET_ZERO_SET (bset); |
EBITSET_ZERO_SET (bset); |
372 |
} |
} |
379 |
|
|
380 |
/* Set all bits in the bitset to zero. */ |
/* Set all bits in the bitset to zero. */ |
381 |
static inline void |
static inline void |
382 |
ebitset_zero (bset) |
ebitset_zero (bitset bset) |
|
bitset bset; |
|
383 |
{ |
{ |
384 |
ebitset_elts *elts; |
ebitset_elts *elts; |
385 |
bitset_windex j; |
bitset_windex j; |
396 |
ebitset_elt_remove (bset, j); |
ebitset_elt_remove (bset, j); |
397 |
} |
} |
398 |
|
|
399 |
/* All the bits are zero. We could shrink the elts. |
/* All the bits are zero. We could shrink the elts. |
400 |
For now just mark BSET as known to be zero. */ |
For now just mark BSET as known to be zero. */ |
401 |
EBITSET_ZERO_SET (bset); |
EBITSET_ZERO_SET (bset); |
402 |
} |
} |
403 |
|
|
404 |
|
|
405 |
static inline int |
static inline int |
406 |
ebitset_equal_p (dst, src) |
ebitset_equal_p (bitset dst, bitset src) |
|
bitset dst; |
|
|
bitset src; |
|
407 |
{ |
{ |
408 |
ebitset_elts *selts; |
ebitset_elts *selts; |
409 |
ebitset_elts *delts; |
ebitset_elts *delts; |
442 |
|
|
443 |
/* Copy bits from bitset SRC to bitset DST. */ |
/* Copy bits from bitset SRC to bitset DST. */ |
444 |
static inline void |
static inline void |
445 |
ebitset_copy_ (dst, src) |
ebitset_copy_ (bitset dst, bitset src) |
|
bitset dst; |
|
|
bitset src; |
|
446 |
{ |
{ |
447 |
ebitset_elts *selts; |
ebitset_elts *selts; |
448 |
ebitset_elts *delts; |
ebitset_elts *delts; |
479 |
/* Copy bits from bitset SRC to bitset DST. Return non-zero if |
/* Copy bits from bitset SRC to bitset DST. Return non-zero if |
480 |
bitsets different. */ |
bitsets different. */ |
481 |
static inline int |
static inline int |
482 |
ebitset_copy_cmp (dst, src) |
ebitset_copy_cmp (bitset dst, bitset src) |
|
bitset dst; |
|
|
bitset src; |
|
483 |
{ |
{ |
484 |
if (src == dst) |
if (src == dst) |
485 |
return 0; |
return 0; |
500 |
|
|
501 |
/* Return size in bits of bitset SRC. */ |
/* Return size in bits of bitset SRC. */ |
502 |
static bitset_bindex |
static bitset_bindex |
503 |
ebitset_size (src) |
ebitset_size (bitset src) |
|
bitset src; |
|
504 |
{ |
{ |
505 |
/* Return current size of bitset in bits. */ |
/* Return current size of bitset in bits. */ |
506 |
return EBITSET_SIZE (src) * EBITSET_ELT_BITS; |
return EBITSET_SIZE (src) * EBITSET_ELT_BITS; |
509 |
|
|
510 |
/* Set bit BITNO in bitset DST. */ |
/* Set bit BITNO in bitset DST. */ |
511 |
static void |
static void |
512 |
ebitset_set (dst, bitno) |
ebitset_set (bitset dst, bitset_bindex bitno) |
|
bitset dst; |
|
|
bitset_bindex bitno; |
|
513 |
{ |
{ |
514 |
bitset_windex windex = bitno / BITSET_WORD_BITS; |
bitset_windex windex = bitno / BITSET_WORD_BITS; |
515 |
|
|
522 |
|
|
523 |
/* Reset bit BITNO in bitset DST. */ |
/* Reset bit BITNO in bitset DST. */ |
524 |
static void |
static void |
525 |
ebitset_reset (dst, bitno) |
ebitset_reset (bitset dst, bitset_bindex bitno) |
|
bitset dst; |
|
|
bitset_bindex bitno; |
|
526 |
{ |
{ |
527 |
bitset_windex windex = bitno / BITSET_WORD_BITS; |
bitset_windex windex = bitno / BITSET_WORD_BITS; |
528 |
|
|
532 |
dst->b.cdata[windex - dst->b.cindex] &= |
dst->b.cdata[windex - dst->b.cindex] &= |
533 |
~((bitset_word) 1 << (bitno % BITSET_WORD_BITS)); |
~((bitset_word) 1 << (bitno % BITSET_WORD_BITS)); |
534 |
|
|
535 |
/* If all the data is zero, perhaps we should remove it now... |
/* If all the data is zero, perhaps we should remove it now... |
536 |
However, there is a good chance that the element will be needed |
However, there is a good chance that the element will be needed |
537 |
again soon. */ |
again soon. */ |
538 |
} |
} |
540 |
|
|
541 |
/* Test bit BITNO in bitset SRC. */ |
/* Test bit BITNO in bitset SRC. */ |
542 |
static int |
static int |
543 |
ebitset_test (src, bitno) |
ebitset_test (bitset src, bitset_bindex bitno) |
|
bitset src; |
|
|
bitset_bindex bitno; |
|
544 |
{ |
{ |
545 |
bitset_windex windex = bitno / BITSET_WORD_BITS; |
bitset_windex windex = bitno / BITSET_WORD_BITS; |
546 |
|
|
553 |
|
|
554 |
|
|
555 |
static void |
static void |
556 |
ebitset_free (bset) |
ebitset_free (bitset bset) |
|
bitset bset; |
|
557 |
{ |
{ |
558 |
ebitset_zero (bset); |
ebitset_zero (bset); |
559 |
free (EBITSET_ELTS (bset)); |
free (EBITSET_ELTS (bset)); |
564 |
*NEXT and store in array LIST. Return with actual number of bits |
*NEXT and store in array LIST. Return with actual number of bits |
565 |
found and with *NEXT indicating where search stopped. */ |
found and with *NEXT indicating where search stopped. */ |
566 |
static bitset_bindex |
static bitset_bindex |
567 |
ebitset_list_reverse (bset, list, num, next) |
ebitset_list_reverse (bitset bset, bitset_bindex *list, |
568 |
bitset bset; |
bitset_bindex num, bitset_bindex *next) |
|
bitset_bindex *list; |
|
|
bitset_bindex num; |
|
|
bitset_bindex *next; |
|
569 |
{ |
{ |
570 |
bitset_bindex n_bits; |
bitset_bindex n_bits; |
571 |
bitset_bindex bitno; |
bitset_bindex bitno; |
608 |
{ |
{ |
609 |
ebitset_elt *elt; |
ebitset_elt *elt; |
610 |
bitset_word *srcp; |
bitset_word *srcp; |
611 |
|
|
612 |
elt = elts[eindex]; |
elt = elts[eindex]; |
613 |
if (elt) |
if (elt) |
614 |
{ |
{ |
615 |
srcp = EBITSET_WORDS (elt); |
srcp = EBITSET_WORDS (elt); |
616 |
|
|
617 |
do |
do |
618 |
{ |
{ |
619 |
bitset_word word; |
bitset_word word; |
620 |
|
|
621 |
word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount); |
word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount); |
622 |
|
|
623 |
for (; word; bcount--) |
for (; word; bcount--) |
624 |
{ |
{ |
625 |
if (word & BITSET_MSB) |
if (word & BITSET_MSB) |
634 |
word <<= 1; |
word <<= 1; |
635 |
} |
} |
636 |
boffset -= BITSET_WORD_BITS; |
boffset -= BITSET_WORD_BITS; |
637 |
bcount = BITSET_WORD_BITS - 1; |
bcount = BITSET_WORD_BITS - 1; |
638 |
} |
} |
639 |
while (woffset--); |
while (woffset--); |
640 |
} |
} |
653 |
*NEXT and store in array LIST. Return with actual number of bits |
*NEXT and store in array LIST. Return with actual number of bits |
654 |
found and with *NEXT indicating where search stopped. */ |
found and with *NEXT indicating where search stopped. */ |
655 |
static bitset_bindex |
static bitset_bindex |
656 |
ebitset_list (bset, list, num, next) |
ebitset_list (bitset bset, bitset_bindex *list, |
657 |
bitset bset; |
bitset_bindex num, bitset_bindex *next) |
|
bitset_bindex *list; |
|
|
bitset_bindex num; |
|
|
bitset_bindex *next; |
|
658 |
{ |
{ |
659 |
bitset_bindex bitno; |
bitset_bindex bitno; |
660 |
bitset_windex windex; |
bitset_windex windex; |
790 |
|
|
791 |
|
|
792 |
static void |
static void |
793 |
ebitset_ones (dst) |
ebitset_ones (bitset dst) |
|
bitset dst; |
|
794 |
{ |
{ |
795 |
bitset_windex j; |
bitset_windex j; |
796 |
ebitset_elt *elt; |
ebitset_elt *elt; |
809 |
|
|
810 |
|
|
811 |
static int |
static int |
812 |
ebitset_empty_p (dst) |
ebitset_empty_p (bitset dst) |
|
bitset dst; |
|
813 |
{ |
{ |
814 |
return !ebitset_weed (dst); |
return !ebitset_weed (dst); |
815 |
} |
} |
816 |
|
|
817 |
|
|
818 |
static void |
static void |
819 |
ebitset_not (dst, src) |
ebitset_not (bitset dst, bitset src) |
|
bitset dst; |
|
|
bitset src; |
|
820 |
{ |
{ |
821 |
unsigned int i; |
unsigned int i; |
822 |
ebitset_elt *selt; |
ebitset_elt *selt; |
836 |
EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i]; |
EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i]; |
837 |
} |
} |
838 |
EBITSET_NONZERO_SET (dst); |
EBITSET_NONZERO_SET (dst); |
839 |
} |
} |
840 |
|
|
841 |
|
|
842 |
/* Return 1 if DST == DST | SRC. */ |
/* Return 1 if DST == DST | SRC. */ |
843 |
static int |
static int |
844 |
ebitset_subset_p (dst, src) |
ebitset_subset_p (bitset dst, bitset src) |
|
bitset dst; |
|
|
bitset src; |
|
845 |
{ |
{ |
846 |
bitset_windex j; |
bitset_windex j; |
847 |
ebitset_elts *selts; |
ebitset_elts *selts; |
848 |
ebitset_elts *delts; |
ebitset_elts *delts; |
849 |
bitset_windex ssize; |
bitset_windex ssize; |
850 |
bitset_windex dsize; |
bitset_windex dsize; |
851 |
|
|
852 |
selts = EBITSET_ELTS (src); |
selts = EBITSET_ELTS (src); |
853 |
delts = EBITSET_ELTS (dst); |
delts = EBITSET_ELTS (dst); |
854 |
|
|
855 |
ssize = EBITSET_SIZE (src); |
ssize = EBITSET_SIZE (src); |
856 |
dsize = EBITSET_SIZE (dst); |
dsize = EBITSET_SIZE (dst); |
857 |
|
|
858 |
for (j = 0; j < ssize; j++) |
for (j = 0; j < ssize; j++) |
859 |
{ |
{ |
860 |
unsigned int i; |
unsigned int i; |
863 |
|
|
864 |
selt = j < ssize ? selts[j] : 0; |
selt = j < ssize ? selts[j] : 0; |
865 |
delt = j < dsize ? delts[j] : 0; |
delt = j < dsize ? delts[j] : 0; |
866 |
|
|
867 |
if (!selt && !delt) |
if (!selt && !delt) |
868 |
continue; |
continue; |
869 |
|
|
870 |
if (!selt) |
if (!selt) |
871 |
selt = &ebitset_zero_elts[0]; |
selt = &ebitset_zero_elts[0]; |
872 |
if (!delt) |
if (!delt) |
873 |
delt = &ebitset_zero_elts[0]; |
delt = &ebitset_zero_elts[0]; |
874 |
|
|
875 |
for (i = 0; i < EBITSET_ELT_WORDS; i++) |
for (i = 0; i < EBITSET_ELT_WORDS; i++) |
876 |
if (EBITSET_WORDS (delt)[i] |
if (EBITSET_WORDS (delt)[i] |
877 |
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i])) |
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i])) |
883 |
|
|
884 |
/* Return 1 if DST & SRC == 0. */ |
/* Return 1 if DST & SRC == 0. */ |
885 |
static int |
static int |
886 |
ebitset_disjoint_p (dst, src) |
ebitset_disjoint_p (bitset dst, bitset src) |
|
bitset dst; |
|
|
bitset src; |
|
887 |
{ |
{ |
888 |
bitset_windex j; |
bitset_windex j; |
889 |
ebitset_elts *selts; |
ebitset_elts *selts; |
890 |
ebitset_elts *delts; |
ebitset_elts *delts; |
891 |
bitset_windex ssize; |
bitset_windex ssize; |
892 |
bitset_windex dsize; |
bitset_windex dsize; |
893 |
|
|
894 |
selts = EBITSET_ELTS (src); |
selts = EBITSET_ELTS (src); |
895 |
delts = EBITSET_ELTS (dst); |
delts = EBITSET_ELTS (dst); |
896 |
|
|
897 |
ssize = EBITSET_SIZE (src); |
ssize = EBITSET_SIZE (src); |
898 |
dsize = EBITSET_SIZE (dst); |
dsize = EBITSET_SIZE (dst); |
899 |
|
|
900 |
for (j = 0; j < ssize; j++) |
for (j = 0; j < ssize; j++) |
901 |
{ |
{ |
902 |
unsigned int i; |
unsigned int i; |
905 |
|
|
906 |
selt = j < ssize ? selts[j] : 0; |
selt = j < ssize ? selts[j] : 0; |
907 |
delt = j < dsize ? delts[j] : 0; |
delt = j < dsize ? delts[j] : 0; |
908 |
|
|
909 |
if (!selt || !delt) |
if (!selt || !delt) |
910 |
continue; |
continue; |
911 |
|
|
912 |
for (i = 0; i < EBITSET_ELT_WORDS; i++) |
for (i = 0; i < EBITSET_ELT_WORDS; i++) |
913 |
if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i])) |
if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i])) |
914 |
return 0; |
return 0; |
919 |
|
|
920 |
|
|
921 |
static int |
static int |
922 |
ebitset_op3_cmp (dst, src1, src2, op) |
ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) |
|
bitset dst; |
|
|
bitset src1; |
|
|
bitset src2; |
|
|
enum_bitset_ops op; |
|
923 |
{ |
{ |
924 |
bitset_windex ssize1; |
bitset_windex ssize1; |
925 |
bitset_windex ssize2; |
bitset_windex ssize2; |
1067 |
} |
} |
1068 |
|
|
1069 |
|
|
|
static void |
|
|
ebitset_and (dst, src1, src2) |
|
|
bitset dst; |
|
|
bitset src1; |
|
|
bitset src2; |
|
|
{ |
|
|
ebitset_and_cmp (dst, src1, src2); |
|
|
} |
|
|
|
|
|
|
|
1070 |
static int |
static int |
1071 |
ebitset_and_cmp (dst, src1, src2) |
ebitset_and_cmp (bitset dst, bitset src1, bitset src2) |
|
bitset dst; |
|
|
bitset src1; |
|
|
bitset src2; |
|
1072 |
{ |
{ |
1073 |
int changed; |
int changed; |
1074 |
|
|
1091 |
|
|
1092 |
|
|
1093 |
static void |
static void |
1094 |
ebitset_andn (dst, src1, src2) |
ebitset_and (bitset dst, bitset src1, bitset src2) |
|
bitset dst; |
|
|
bitset src1; |
|
|
bitset src2; |
|
1095 |
{ |
{ |
1096 |
ebitset_andn_cmp (dst, src1, src2); |
ebitset_and_cmp (dst, src1, src2); |
1097 |
} |
} |
1098 |
|
|
1099 |
|
|
1100 |
static int |
static int |
1101 |
ebitset_andn_cmp (dst, src1, src2) |
ebitset_andn_cmp (bitset dst, bitset src1, bitset src2) |
|
bitset dst; |
|
|
bitset src1; |
|
|
bitset src2; |
|
1102 |
{ |
{ |
1103 |
int changed; |
int changed; |
1104 |
|
|
1118 |
|
|
1119 |
|
|
1120 |
static void |
static void |
1121 |
ebitset_or (dst, src1, src2) |
ebitset_andn (bitset dst, bitset src1, bitset src2) |
|
bitset dst; |
|
|
bitset src1; |
|
|
bitset src2; |
|
1122 |
{ |
{ |
1123 |
ebitset_or_cmp (dst, src1, src2); |
ebitset_andn_cmp (dst, src1, src2); |
1124 |
} |
} |
1125 |
|
|
1126 |
|
|
1127 |
static int |
static int |
1128 |
ebitset_or_cmp (dst, src1, src2) |
ebitset_or_cmp (bitset dst, bitset src1, bitset src2) |
|
bitset dst; |
|
|
bitset src1; |
|
|
bitset src2; |
|
1129 |
{ |
{ |
1130 |
if (EBITSET_ZERO_P (src2)) |
if (EBITSET_ZERO_P (src2)) |
1131 |
{ |
{ |
1140 |
|
|
1141 |
|
|
1142 |
static void |
static void |
1143 |
ebitset_xor (dst, src1, src2) |
ebitset_or (bitset dst, bitset src1, bitset src2) |
|
bitset dst; |
|
|
bitset src1; |
|
|
bitset src2; |
|
1144 |
{ |
{ |
1145 |
ebitset_xor_cmp (dst, src1, src2); |
ebitset_or_cmp (dst, src1, src2); |
1146 |
} |
} |
1147 |
|
|
1148 |
|
|
1149 |
static int |
static int |
1150 |
ebitset_xor_cmp (dst, src1, src2) |
ebitset_xor_cmp (bitset dst, bitset src1, bitset src2) |
|
bitset dst; |
|
|
bitset src1; |
|
|
bitset src2; |
|
1151 |
{ |
{ |
1152 |
if (EBITSET_ZERO_P (src2)) |
if (EBITSET_ZERO_P (src2)) |
1153 |
{ |
{ |
1162 |
|
|
1163 |
|
|
1164 |
static void |
static void |
1165 |
ebitset_copy (dst, src) |
ebitset_xor (bitset dst, bitset src1, bitset src2) |
1166 |
bitset dst; |
{ |
1167 |
bitset src; |
ebitset_xor_cmp (dst, src1, src2); |
1168 |
|
} |
1169 |
|
|
1170 |
|
|
1171 |
|
static void |
1172 |
|
ebitset_copy (bitset dst, bitset src) |
1173 |
{ |
{ |
1174 |
if (BITSET_COMPATIBLE_ (dst, src)) |
if (BITSET_COMPATIBLE_ (dst, src)) |
1175 |
ebitset_copy_ (dst, src); |
ebitset_copy_ (dst, src); |
1217 |
|
|
1218 |
/* Return size of initial structure. */ |
/* Return size of initial structure. */ |
1219 |
size_t |
size_t |
1220 |
ebitset_bytes (n_bits) |
ebitset_bytes (bitset_bindex n_bits ATTRIBUTE_UNUSED) |
|
bitset_bindex n_bits ATTRIBUTE_UNUSED; |
|
1221 |
{ |
{ |
1222 |
return sizeof (struct ebitset_struct); |
return sizeof (struct ebitset_struct); |
1223 |
} |
} |
1226 |
/* Initialize a bitset. */ |
/* Initialize a bitset. */ |
1227 |
|
|
1228 |
bitset |
bitset |
1229 |
ebitset_init (bset, n_bits) |
ebitset_init (bitset bset, bitset_bindex n_bits) |
|
bitset bset; |
|
|
bitset_bindex n_bits; |
|
1230 |
{ |
{ |
1231 |
bitset_windex size; |
bitset_windex size; |
1232 |
|
|
1248 |
|
|
1249 |
|
|
1250 |
void |
void |
1251 |
ebitset_release_memory () |
ebitset_release_memory (void) |
1252 |
{ |
{ |
1253 |
ebitset_free_list = 0; |
ebitset_free_list = 0; |
1254 |
if (ebitset_obstack_init) |
if (ebitset_obstack_init) |