be zero.
The bitset cache can be disabled either by setting cindex to
- some large number or by setting csize to 0. Here
+ BITSET_WINDEX_MAX or by setting csize to 0. Here
we use the former approach since cindex needs to be updated whenever
cdata is changed.
*/
/* Head of ebitset linked list. */
typedef struct ebitset_struct
{
- unsigned int size; /* Number of elements. */
+ bitset_windex size; /* Number of elements. */
ebitset_elts *elts; /* Expanding array of pointers to elements. */
}
*ebitset;
static int ebitset_obstack_init = 0;
static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
-static void ebitset_elts_grow PARAMS ((bitset, unsigned int));
+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 *, unsigned int));
-static void ebitset_elt_remove PARAMS ((bitset, unsigned int));
+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 int ebitset_weed PARAMS ((bitset));
+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 int ebitset_size PARAMS ((bitset));
+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_andn_cmp PARAMS ((bitset, bitset, bitset));
static int ebitset_or_cmp PARAMS ((bitset, bitset, bitset));
static int ebitset_xor_cmp PARAMS ((bitset, bitset, bitset));
-static int ebitset_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
- bitset_bindex *));
-static int ebitset_list_reverse
+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_free PARAMS ((bitset));
#define EBITSET_WORDS(ELT) ((ELT)->u.words)
/* Disable bitset cache and mark BSET as being zero. */
-#define EBITSET_ZERO_SET(BSET) ((BSET)->b.cindex = BITSET_INDEX_MAX, \
+#define EBITSET_ZERO_SET(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX, \
(BSET)->b.cdata = 0)
-#define EBITSET_CACHE_DISABLE(BSET) ((BSET)->b.cindex = BITSET_INDEX_MAX)
+#define EBITSET_CACHE_DISABLE(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX)
/* Disable bitset cache and mark BSET as being possibly non-zero. */
#define EBITSET_NONZERO_SET(BSET) \
static void
ebitset_elts_grow (bset, size)
bitset bset;
- unsigned int size;
+ bitset_windex size;
{
- unsigned int oldsize;
- unsigned int newsize;
+ bitset_windex oldsize;
+ bitset_windex newsize;
oldsize = EBITSET_SIZE (bset);
newsize = oldsize + size;
+ if (BITSET_SIZE_MAX / sizeof (ebitset_elt *) < newsize)
+ xalloc_die ();
+
EBITSET_ELTS (bset) = xrealloc (EBITSET_ELTS (bset),
newsize * sizeof (ebitset_elt *));
EBITSET_SIZE (bset) = newsize;
static inline void
ebitset_elt_remove (bset, eindex)
bitset bset;
- unsigned int eindex;
+ bitset_windex eindex;
{
ebitset_elts *elts;
ebitset_elt *elt;
ebitset_elt_add (bset, elt, eindex)
bitset bset;
ebitset_elt *elt;
- unsigned int eindex;
+ bitset_windex eindex;
{
ebitset_elts *elts;
{
ebitset_elt *elt;
bitset_windex size;
- unsigned int eindex;
+ bitset_windex eindex;
ebitset_elts *elts;
eindex = windex / EBITSET_ELT_WORDS;
case EBITSET_CREATE:
if (eindex >= size)
{
- unsigned int extra;
+ bitset_windex extra;
extra = eindex - size + 1;
/* Weed out the zero elements from the elts. */
-static inline int
+static inline bitset_windex
ebitset_weed (bset)
bitset bset;
{
ebitset_elts *elts;
bitset_windex j;
- int count;
+ bitset_windex count;
if (EBITSET_ZERO_P (bset))
return 0;
/* Return size in bits of bitset SRC. */
-static int
+static bitset_bindex
ebitset_size (src)
bitset src;
{
/* 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
found and with *NEXT indicating where search stopped. */
-static int
+static bitset_bindex
ebitset_list_reverse (bset, list, num, next)
bitset bset;
bitset_bindex *list;
unsigned int bcount;
bitset_bindex boffset;
bitset_windex windex;
- unsigned int eindex;
+ bitset_windex eindex;
bitset_windex woffset;
bitset_bindex count;
bitset_windex size;
/* 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
found and with *NEXT indicating where search stopped. */
-static int
+static bitset_bindex
ebitset_list (bset, list, num, next)
bitset bset;
bitset_bindex *list;
{
bitset_bindex bitno;
bitset_windex windex;
- unsigned int eindex;
+ bitset_windex eindex;
bitset_bindex count;
bitset_windex size;
ebitset_elt *elt;
/* Return size of initial structure. */
-int
+size_t
ebitset_bytes (n_bits)
bitset_bindex n_bits ATTRIBUTE_UNUSED;
{
bitset bset;
bitset_bindex n_bits;
{
- unsigned int size;
+ bitset_windex size;
bset->b.vtable = &ebitset_vtable;