bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

More bitset patches for 64-bit hosts


From: Paul Eggert
Subject: More bitset patches for 64-bit hosts
Date: Wed, 2 Oct 2002 01:21:00 -0700 (PDT)

> Date: Sat, 28 Sep 2002 14:56:06 +1200
> From: Michael Hayes <address@hidden>
> 
> I've attached my lastest version incorporating Paul's fixes and
> Marks suggestions.

Thanks.  Next time, can you please also send ChangeLog entries?

I looked over the latest Bison bitset code and fixed several other
64-bit-host porting problems that I had noticed earlier but hadn't had
time to fix.  So I installed the enclosed patch into the Bison CVS.

There might be one little interface gotcha here, since this patch does
a xalloc_die () when memory-size calculations overflow.  Bison and
many other GNU utilities have an xalloc_die along with xmalloc, and it
is the tradition to call xalloc_die () when asked to allocate more
than SIZE_MAX bytes, but I don't know if that's part of the bitset
code's interface spec.


2002-10-01  Paul Eggert  <address@hidden>

        More fixes for 64-bit hosts and large bitsets.

        * lib/abitset.c (struct abitset_struct.n_bits, abitset_small_list,
        abitset_size, abitset_list, abitset_list_reverse, abitset_list):
        Use bitset_bindex, not int or unsigned int or size_t, to count bits.
        * lib/bbitset.h (struct bitset_vtable.size, struct bitset_vtable.count,
        struct bitset_vtable.list, struct bitset_vtable.list_reverse,
        bitset_count_, bitset_next, bitset_prev, bitset_first, bitset_last,
        bitset_count_): Likewise.
        * lib/bitset.h (bitset_iterator.num, bitset_iterator.i,
        bitset_first, bitset_last): Likewise.
        * lib/bitset_stats.c (bitset_stats_size, bitset_stats_list,
        bitset_stats_list_reverse, bitset_stats_size,
        bitset_stats_count, bitset_stats_list, bitset_stat_list_reverse):
        Likewise.
        * lib/bitsetv-print.c (bitsetv_matrix_dump): Likewise.
        * lib/bitsetv.c (bitsetv_alloc, bitsetv_create, bitsetv_free,
        bitsetv_zero, bitsetv_ones, bitsetv_transitive_closure,
        bitsetv_reflexive_transitive_closure): Likewise.
        * lib/bitsetv.h (bitsetv_alloc, bitsetv_create): Likewise.
        * lib/ebitset.c (ebitset_size, ebitset_list, ebitset_list_reverse):
        Likewise.
        * lib/lbitset.c (lbitset_size, lbitset_list, lbitset_list_merge):
        Likewise.
        
        * lib/abitset.c (abitset_ones, abitset_zero, abitset_bytes):
        Use size_t, not unsigned int, to count bytes.
        * lib/abitset.h (abitset_bytes): Likewise.
        * lib/bitset.c (bitset_bytes, bitset_alloc, bitset_obstack_alloc):
        Likewise.
        * lib/bitset.h (bitset_bytes): Likewise.
        * lib/bitset_stats.c (bitset_stats_bytes, bitset_stats_init): Likewise.
        * lib/bitset_stats.h (bitset_stats_bytes): Likewise.
        * lib/bitsetv.c (bitsetv_alloc): Likewise.
        * lib/ebitset.c (ebitset_bytes): Likewise.
        * lib/ebitset.h (ebitset_bytes): Likewise.
        * lib/lbitset.c (lbitset_bytes): Likewise.
        * lib/lbitset.h (lbitset_bytes): Likewise.
        
        * lib/abitset.c (abitset_empty_p, abitset_not, abitset_equal_p,
        abitset_subset_p, abitset_disjoint_p, abitset_and,
        abitset_and_cmp, abitset_andn, abitset_andn_cmp, abitset_or,
        abitset_or_cmp, abitset_xor, abitset_xor_cmp, abitset_and_or,
        abitset_and_or_cmp, abitset_andn_or, abitset_andn_or_cmp,
        abitset_or_and, abitset_or_and_cmp):
        Use bitset_windex instead of unsigned int.
        * lib/bitsetv.c (bitsetv_dump, debug_bitsetv): Likewise.
        * lib/ebitset.c (struct ebitset_struct.size, ebitset_elts_grow,
        ebitset_elt_add, ebitset_elt_remove, ebitset_weed,
        ebitset_elt_find, ebitset_list_reverse, ebitset_list, ebitset_init):
        Likewise.
        * lib/lbitset.c (lbitset_ones, lbitset_not): Likewise.
        
        * lib/bitset.c (bitset_print):
        Use proper printf formats for widths of integer types.
        * lib/bitset_stats.c (bitset_percent_histogram_print,
        bitset_log_histogram_print, bitset_stats_print_1): Likewise.
        * lib/bitsetv-print.c (bitsetv_matrix_dump): Likewise.
        * lib/bitsetv.c (bitsetv_dump, debug_bitsetv): Likewise.
        * lib/lbitset.c (lbitset_bytes): Likewise.
        
        * lib/bbitset.h (BITSET_BINDEX_MAX, BITSET_WINDEX_MAX,
        BITSET_SIZE_MAX): New macros.
        (BITSET_INDEX_MAX): Remove.  It wasn't right, since it assumed that
        sizeof (bitset_word) == sizeof (bitset_windex).  All uses changed
        to BITSET_WINDEX_MAX.

        * lib/bitset.c (bitset_next, bitset_prev, bitset_first,
        bitset_last): Return BITSET_BINDEX_MAX (not -1) for no value,
        since we now return the bitset_bindex type (not int).

        * lib/bitsetv.c (bitsetv_alloc): Check for arithmetic overflow
        when computing sizes.
        * lib/ebitset.c (ebitset_elts_grow): Likewise.

        * lib/lbitset.c (lbitset_elt_find): Simplify windex calculation
        and avoid cast to unsigned.

diff -pru older/lib/abitset.c bison/lib/abitset.c
--- older/lib/abitset.c 2002-09-30 05:50:49.000000000 -0700
+++ bison/lib/abitset.c 2002-10-02 00:41:04.000000000 -0700
@@ -30,7 +30,7 @@
 
 typedef struct abitset_struct
 {
-  unsigned int n_bits; /* Number of bits.  */
+  bitset_bindex n_bits;        /* Number of bits.  */
   bitset_word words[1];        /* The array of bits.  */
 }
 *abitset;
@@ -44,16 +44,17 @@ struct bitset_struct
 
 static void abitset_unused_clear PARAMS ((bitset));
 
-static int abitset_small_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
-                                      bitset_bindex *));
+static bitset_bindex abitset_small_list PARAMS ((bitset, bitset_bindex *,
+                                                bitset_bindex,
+                                                bitset_bindex *));
 
 static void abitset_set PARAMS ((bitset, bitset_bindex));
 static void abitset_reset PARAMS ((bitset, bitset_bindex));
 static int abitset_test PARAMS ((bitset, bitset_bindex));
-static int abitset_size PARAMS ((bitset));
-static int abitset_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
-                                bitset_bindex *));
-static int abitset_list_reverse
+static bitset_bindex abitset_size PARAMS ((bitset));
+static bitset_bindex abitset_list PARAMS ((bitset, bitset_bindex *,
+                                          bitset_bindex, bitset_bindex *));
+static bitset_bindex abitset_list_reverse
 PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *));
 
 #define ABITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
@@ -62,7 +63,7 @@ PARAMS ((bitset, bitset_bindex *, bitset
 
 
 /* Return size in bits of bitset SRC.  */
-static int
+static bitset_bindex
 abitset_size (src)
      bitset src;
 {
@@ -73,7 +74,7 @@ abitset_size (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
 abitset_small_list (src, list, num, next)
      bitset src;
      bitset_bindex *list;
@@ -173,7 +174,7 @@ abitset_test (src, bitno)
    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
 abitset_list_reverse (src, list, num, next)
      bitset src;
      bitset_bindex *list;
@@ -236,7 +237,7 @@ abitset_list_reverse (src, list, num, ne
 /* 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
 abitset_list (src, list, num, next)
      bitset src;
      bitset_bindex *list;
@@ -358,7 +359,7 @@ abitset_ones (dst)
      bitset dst;
 {
   bitset_word *dstp = ABITSET_WORDS (dst);
-  unsigned int bytes;
+  size_t bytes;
 
   bytes = sizeof (bitset_word) * dst->b.csize;
 
@@ -372,7 +373,7 @@ abitset_zero (dst)
      bitset dst;
 {
   bitset_word *dstp = ABITSET_WORDS (dst);
-  unsigned int bytes;
+  size_t bytes;
 
   bytes = sizeof (bitset_word) * dst->b.csize;
 
@@ -384,7 +385,7 @@ static int
 abitset_empty_p (dst)
      bitset dst;
 {
-  unsigned int i;
+  bitset_windex i;
   bitset_word *dstp = ABITSET_WORDS (dst);
 
   for (i = 0; i < dst->b.csize; i++)
@@ -415,7 +416,7 @@ abitset_not (dst, src)
      bitset dst;
      bitset src;
 {
-  unsigned int i;
+  bitset_windex i;
   bitset_word *srcp = ABITSET_WORDS (src);
   bitset_word *dstp = ABITSET_WORDS (dst);
   bitset_windex size = dst->b.csize;
@@ -431,7 +432,7 @@ abitset_equal_p (dst, src)
      bitset dst;
      bitset src;
 {
-  unsigned int i;
+  bitset_windex i;
   bitset_word *srcp = ABITSET_WORDS (src);
   bitset_word *dstp = ABITSET_WORDS (dst);
   bitset_windex size = dst->b.csize;
@@ -448,7 +449,7 @@ abitset_subset_p (dst, src)
      bitset dst;
      bitset src;
 {
-  unsigned int i;
+  bitset_windex i;
   bitset_word *srcp = ABITSET_WORDS (src);
   bitset_word *dstp = ABITSET_WORDS (dst);
   bitset_windex size = dst->b.csize;
@@ -465,7 +466,7 @@ abitset_disjoint_p (dst, src)
      bitset dst;
      bitset src;
 {
-  unsigned int i;
+  bitset_windex i;
   bitset_word *srcp = ABITSET_WORDS (src);
   bitset_word *dstp = ABITSET_WORDS (dst);
   bitset_windex size = dst->b.csize;
@@ -484,7 +485,7 @@ abitset_and (dst, src1, src2)
      bitset src1;
      bitset src2;
 {
-  unsigned int i;
+  bitset_windex i;
   bitset_word *src1p = ABITSET_WORDS (src1);
   bitset_word *src2p = ABITSET_WORDS (src2);
   bitset_word *dstp = ABITSET_WORDS (dst);
@@ -501,7 +502,7 @@ abitset_and_cmp (dst, src1, src2)
      bitset src1;
      bitset src2;
 {
-  unsigned int i;
+  bitset_windex i;
   int changed = 0;
   bitset_word *src1p = ABITSET_WORDS (src1);
   bitset_word *src2p = ABITSET_WORDS (src2);
@@ -528,7 +529,7 @@ abitset_andn (dst, src1, src2)
      bitset src1;
      bitset src2;
 {
-  unsigned int i;
+  bitset_windex i;
   bitset_word *src1p = ABITSET_WORDS (src1);
   bitset_word *src2p = ABITSET_WORDS (src2);
   bitset_word *dstp = ABITSET_WORDS (dst);
@@ -545,7 +546,7 @@ abitset_andn_cmp (dst, src1, src2)
      bitset src1;
      bitset src2;
 {
-  unsigned int i;
+  bitset_windex i;
   int changed = 0;
   bitset_word *src1p = ABITSET_WORDS (src1);
   bitset_word *src2p = ABITSET_WORDS (src2);
@@ -572,7 +573,7 @@ abitset_or (dst, src1, src2)
      bitset src1;
      bitset src2;
 {
-  unsigned int i;
+  bitset_windex i;
   bitset_word *src1p = ABITSET_WORDS (src1);
   bitset_word *src2p = ABITSET_WORDS (src2);
   bitset_word *dstp = ABITSET_WORDS (dst);
@@ -589,7 +590,7 @@ abitset_or_cmp (dst, src1, src2)
      bitset src1;
      bitset src2;
 {
-  unsigned int i;
+  bitset_windex i;
   int changed = 0;
   bitset_word *src1p = ABITSET_WORDS (src1);
   bitset_word *src2p = ABITSET_WORDS (src2);
@@ -616,7 +617,7 @@ abitset_xor (dst, src1, src2)
      bitset src1;
      bitset src2;
 {
-  unsigned int i;
+  bitset_windex i;
   bitset_word *src1p = ABITSET_WORDS (src1);
   bitset_word *src2p = ABITSET_WORDS (src2);
   bitset_word *dstp = ABITSET_WORDS (dst);
@@ -633,7 +634,7 @@ abitset_xor_cmp (dst, src1, src2)
      bitset src1;
      bitset src2;
 {
-  unsigned int i;
+  bitset_windex i;
   int changed = 0;
   bitset_word *src1p = ABITSET_WORDS (src1);
   bitset_word *src2p = ABITSET_WORDS (src2);
@@ -661,7 +662,7 @@ abitset_and_or (dst, src1, src2, src3)
      bitset src2;
      bitset src3;
 {
-  unsigned int i;
+  bitset_windex i;
   bitset_word *src1p = ABITSET_WORDS (src1);
   bitset_word *src2p = ABITSET_WORDS (src2);
   bitset_word *src3p = ABITSET_WORDS (src3);
@@ -680,7 +681,7 @@ abitset_and_or_cmp (dst, src1, src2, src
      bitset src2;
      bitset src3;
 {
-  unsigned int i;
+  bitset_windex i;
   int changed = 0;
   bitset_word *src1p = ABITSET_WORDS (src1);
   bitset_word *src2p = ABITSET_WORDS (src2);
@@ -709,7 +710,7 @@ abitset_andn_or (dst, src1, src2, src3)
      bitset src2;
      bitset src3;
 {
-  unsigned int i;
+  bitset_windex i;
   bitset_word *src1p = ABITSET_WORDS (src1);
   bitset_word *src2p = ABITSET_WORDS (src2);
   bitset_word *src3p = ABITSET_WORDS (src3);
@@ -728,7 +729,7 @@ abitset_andn_or_cmp (dst, src1, src2, sr
      bitset src2;
      bitset src3;
 {
-  unsigned int i;
+  bitset_windex i;
   int changed = 0;
   bitset_word *src1p = ABITSET_WORDS (src1);
   bitset_word *src2p = ABITSET_WORDS (src2);
@@ -757,7 +758,7 @@ abitset_or_and (dst, src1, src2, src3)
      bitset src2;
      bitset src3;
 {
-  unsigned int i;
+  bitset_windex i;
   bitset_word *src1p = ABITSET_WORDS (src1);
   bitset_word *src2p = ABITSET_WORDS (src2);
   bitset_word *src3p = ABITSET_WORDS (src3);
@@ -776,7 +777,7 @@ abitset_or_and_cmp (dst, src1, src2, src
      bitset src2;
      bitset src3;
 {
-  unsigned int i;
+  bitset_windex i;
   int changed = 0;
   bitset_word *src1p = ABITSET_WORDS (src1);
   bitset_word *src2p = ABITSET_WORDS (src2);
@@ -884,11 +885,12 @@ struct bitset_vtable abitset_vtable = {
 };
 
 
-int
+size_t
 abitset_bytes (n_bits)
      bitset_bindex n_bits;
 {
-  unsigned int bytes, size;
+  bitset_windex size;
+  size_t bytes;
 
   size = ABITSET_N_WORDS (n_bits);
   bytes = size * sizeof (bitset_word);
diff -pru older/lib/abitset.h bison/lib/abitset.h
--- older/lib/abitset.h 2002-07-02 06:51:26.000000000 -0700
+++ bison/lib/abitset.h 2002-10-02 00:42:26.000000000 -0700
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suit
 
 #include "bbitset.h"
 
-extern int abitset_bytes PARAMS ((bitset_bindex));
+extern size_t abitset_bytes PARAMS ((bitset_bindex));
 
 extern bitset abitset_init PARAMS ((bitset, bitset_bindex));
 
diff -pru older/lib/bbitset.h bison/lib/bbitset.h
--- older/lib/bbitset.h 2002-09-30 05:50:49.000000000 -0700
+++ bison/lib/bbitset.h 2002-10-02 00:44:07.000000000 -0700
@@ -51,13 +51,20 @@ typedef unsigned long bitset_word;
 
 /* Bit index.  In theory we might need a type wider than size_t, but
    in practice we lose at most a factor of CHAR_BIT by going with
-   size_t, and that is good enough.  */
+   size_t, and that is good enough.  If this type is changed to be
+   wider than size_t, the code needs to be modified to check for
+   overflow when converting bit counts to byte or word counts.
+   The bit and word index types must be unsigned.  */
 typedef size_t bitset_bindex;
 
 /* Word index.  */
 typedef size_t bitset_windex;
 
-#define BITSET_INDEX_MAX ((bitset_word) 1 << (BITSET_WORD_BITS - 1))
+/* Maximum values for commonly-used unsigned types.  BITSET_SIZE_MAX
+   always equals SIZE_MAX, but some older systems lack SIZE_MAX.  */
+#define BITSET_BINDEX_MAX ((bitset_bindex) -1)
+#define BITSET_WINDEX_MAX ((bitset_windex) -1)
+#define BITSET_SIZE_MAX ((size_t) -1)
 
 #define BITSET_MSB ((bitset_word) 1 << (BITSET_WORD_BITS - 1))
 
@@ -94,8 +101,8 @@ struct bitset_vtable
   void (*reset) PARAMS ((struct bitset_struct *, bitset_bindex));
   int (*toggle) PARAMS ((struct bitset_struct *, bitset_bindex));
   int (*test) PARAMS ((struct bitset_struct *, bitset_bindex));
-  int (*size) PARAMS ((struct bitset_struct *));
-  int (*count) PARAMS ((struct bitset_struct *));
+  bitset_bindex (*size) PARAMS ((struct bitset_struct *));
+  bitset_bindex (*count) PARAMS ((struct bitset_struct *));
 
   int (*empty_p) PARAMS ((struct bitset_struct *));
   void (*ones) PARAMS ((struct bitset_struct *));
@@ -137,10 +144,11 @@ struct bitset_vtable
   int (*or_and_cmp) PARAMS ((struct bitset_struct *, struct bitset_struct *,
                             struct bitset_struct *, struct bitset_struct *));
 
-  int (*list) PARAMS ((struct bitset_struct *, bitset_bindex *,
-                      bitset_bindex, bitset_bindex *));
-  int (*list_reverse) PARAMS ((struct bitset_struct *, bitset_bindex *,
-                              bitset_bindex, bitset_bindex *));
+  bitset_bindex (*list) PARAMS ((struct bitset_struct *, bitset_bindex *,
+                                bitset_bindex, bitset_bindex *));
+  bitset_bindex (*list_reverse) PARAMS ((struct bitset_struct *,
+                                        bitset_bindex *, bitset_bindex,
+                                        bitset_bindex *));
   void (*free) PARAMS ((struct bitset_struct *));
   enum bitset_type type;
 };
@@ -269,7 +277,7 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !
  
 extern int bitset_toggle_ PARAMS ((bitset, bitset_bindex));
 
-extern int bitset_count_ PARAMS ((bitset));
+extern bitset_bindex bitset_count_ PARAMS ((bitset));
 
 extern int bitset_copy_ PARAMS ((bitset, bitset));
 
diff -pru older/lib/bitset.c bison/lib/bitset.c
--- older/lib/bitset.c  2002-09-30 05:50:49.000000000 -0700
+++ bison/lib/bitset.c  2002-10-02 00:45:37.000000000 -0700
@@ -35,12 +35,12 @@ static void bitset_print PARAMS ((FILE *
 
 /* Return number of bytes required to create a N_BIT bitset
    of TYPE.  The bitset may grow to require more bytes than this.  */
-int
+size_t
 bitset_bytes (type, n_bits)
      enum bitset_type type;
      bitset_bindex n_bits;
 {
-  unsigned int bytes;
+  size_t bytes;
 
   if (bitset_stats_enabled)
     return bitset_stats_bytes ();
@@ -132,7 +132,7 @@ bitset_alloc (n_bits, type)
      bitset_bindex n_bits;
      enum bitset_type type;
 {
-  unsigned int bytes;
+  size_t bytes;
   bitset bset;
 
   bytes = bitset_bytes (type, n_bits);
@@ -154,7 +154,7 @@ bitset_obstack_alloc (bobstack, n_bits, 
      bitset_bindex n_bits;
      enum bitset_type type;
 {
-  unsigned int bytes;
+  size_t bytes;
   bitset bset;
 
   bytes = bitset_bytes (type, n_bits);
@@ -229,8 +229,8 @@ bitset_type_name_get (bset)
 
 
 /* Find next bit set in SRC starting from and including BITNO.
-   Return -1 if SRC empty.  */
-int
+   Return BITSET_BINDEX_MAX if SRC empty.  */
+bitset_bindex
 bitset_next (src, bitno)
      bitset src;
      bitset_bindex bitno;
@@ -239,14 +239,14 @@ bitset_next (src, bitno)
   bitset_bindex next = bitno;
 
   if (!bitset_list (src, &val, 1, &next))
-    return -1;
+    return BITSET_BINDEX_MAX;
   return val;
 }
 
 
 /* Find previous bit set in SRC starting from and including BITNO.
-   Return -1 if SRC empty.  */
-int
+   Return BITSET_BINDEX_MAX if SRC empty.  */
+bitset_bindex
 bitset_prev (src, bitno)
      bitset src;
      bitset_bindex bitno;
@@ -255,13 +255,13 @@ bitset_prev (src, bitno)
   bitset_bindex next = bitno;
 
   if (!bitset_list_reverse (src, &val, 1, &next))
-    return -1;
+    return BITSET_BINDEX_MAX;
   return val;
 }
 
 
 /* Find first set bit.   */
-int
+bitset_bindex
 bitset_first (src)
      bitset src;
 {
@@ -270,7 +270,7 @@ bitset_first (src)
 
 
 /* Find last set bit.   */
-int
+bitset_bindex
 bitset_last (src)
      bitset src;
 {
@@ -305,7 +305,8 @@ bitset_print (file, bset, verbose)
   bitset_iterator iter;
 
   if (verbose)
-    fprintf (file, "n_bits = %d, set = {", bitset_size (bset));
+    fprintf (file, "n_bits = %lu, set = {",
+            (unsigned long) bitset_size (bset));
 
   pos = 30;
   BITSET_FOR_EACH (iter, bset, i, 0)
@@ -368,14 +369,14 @@ bitset_toggle_ (bset, bitno)
 
 
 /* Return number of bits set in bitset SRC.  */
-int
+bitset_bindex
 bitset_count_ (src)
      bitset src;
 {
   bitset_bindex list[BITSET_LIST_SIZE];
   bitset_bindex next;
-  int num;
-  int count;
+  bitset_bindex num;
+  bitset_bindex count;
   
   /* This could be greatly sped up by adding a count method for each
      bitset implementation that uses a direct technique (based on
diff -pru older/lib/bitset.h bison/lib/bitset.h
--- older/lib/bitset.h  2002-09-30 05:50:49.000000000 -0700
+++ bison/lib/bitset.h  2002-10-02 00:47:03.000000000 -0700
@@ -51,13 +51,13 @@ typedef struct
 {
   bitset_bindex list[BITSET_LIST_SIZE];
   bitset_bindex next;
-  int num;
-  int i;
+  bitset_bindex num;
+  bitset_bindex i;
 } bitset_iterator;
 
 
 /* Return bytes required for bitset of desired type and size.  */
-extern int bitset_bytes PARAMS ((enum bitset_type, bitset_bindex));
+extern size_t bitset_bytes PARAMS ((enum bitset_type, bitset_bindex));
 
 /* Initialise a bitset with desired type and size.  */
 extern bitset bitset_init PARAMS ((bitset, bitset_bindex, enum bitset_type));
@@ -287,10 +287,10 @@ do                                                        
        \
 
 
 /* Find first set bit.  */
-extern int bitset_first PARAMS ((bitset));
+extern bitset_bindex bitset_first PARAMS ((bitset));
 
 /* Find last set bit.  */
-extern int bitset_last PARAMS ((bitset));
+extern bitset_bindex bitset_last PARAMS ((bitset));
 
 /* Dump bitset.  */
 extern void bitset_dump PARAMS ((FILE *, bitset));
diff -pru older/lib/bitset_stats.c bison/lib/bitset_stats.c
--- older/lib/bitset_stats.c    2002-09-30 05:50:49.000000000 -0700
+++ bison/lib/bitset_stats.c    2002-10-02 00:49:35.000000000 -0700
@@ -120,10 +120,11 @@ static void bitset_stats_set PARAMS ((bi
 static void bitset_stats_reset PARAMS ((bitset, bitset_bindex));
 static int bitset_stats_toggle PARAMS ((bitset, bitset_bindex));
 static int bitset_stats_test PARAMS ((bitset, bitset_bindex));
-static int bitset_stats_size PARAMS ((bitset));
-static int bitset_stats_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
-                                     bitset_bindex *));
-static int bitset_stats_list_reverse
+static bitset_bindex bitset_stats_size PARAMS ((bitset));
+static bitset_bindex bitset_stats_list PARAMS ((bitset, bitset_bindex *,
+                                               bitset_bindex,
+                                               bitset_bindex *));
+static bitset_bindex bitset_stats_list_reverse
 PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *));
 static void bitset_stats_free PARAMS ((bitset));
 static void bitset_percent_histogram_print PARAMS ((FILE *, const char *,
@@ -160,7 +161,7 @@ bitset_percent_histogram_print (file, na
 
   fprintf (file, "%s %s", name, msg);
   for (i = 0; i < n_bins; i++)
-    fprintf (file, "%.0f-%.0f%%\t%8d (%5.1f%%)\n",
+    fprintf (file, "%.0f-%.0f%%\t%8u (%5.1f%%)\n",
             i * 100.0 / n_bins,
             (i + 1) * 100.0 / n_bins, bins[i],
             (100.0 * bins[i]) / total);
@@ -197,13 +198,15 @@ bitset_log_histogram_print (file, name, 
 
   fprintf (file, "%s %s", name, msg);
   for (i = 0; i < 2; i++)
-    fprintf (file, "%*d\t%8d (%5.1f%%)\n",
+    fprintf (file, "%*d\t%8u (%5.1f%%)\n",
             max_width, i, bins[i], 100.0 * bins[i] / total);
 
   for (; i < n_bins; i++)
-    fprintf (file, "%*d-%d\t%8d (%5.1f%%)\n",
+    fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
             max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
-            1 << (i - 1), (1 << i) - 1, bins[i],
+            (unsigned long) 1 << (i - 1),
+            ((unsigned long) 1 << i) - 1,
+            bins[i],
             (100.0 * bins[i]) / total);
 }
 
@@ -219,20 +222,20 @@ bitset_stats_print_1 (file, name, stats)
     return;
   
   fprintf (file, "%s:\n", name);
-  fprintf (file, _("%d bitset_allocs, %d freed (%.2f%%).\n"),
+  fprintf (file, _("%u bitset_allocs, %u freed (%.2f%%).\n"),
           stats->allocs, stats->frees,
           stats->allocs ? 100.0 * stats->frees / stats->allocs : 0);
-  fprintf (file, _("%d bitset_sets, %d cached (%.2f%%)\n"),
+  fprintf (file, _("%u bitset_sets, %u cached (%.2f%%)\n"),
           stats->sets, stats->cache_sets,
           stats->sets ? 100.0 * stats->cache_sets / stats->sets : 0);
-  fprintf (file, _("%d bitset_resets, %d cached (%.2f%%)\n"),
+  fprintf (file, _("%u bitset_resets, %u cached (%.2f%%)\n"),
           stats->resets, stats->cache_resets,
           stats->resets ? 100.0 * stats->cache_resets / stats->resets : 0);
-  fprintf (file, _("%d bitset_tests, %d cached (%.2f%%)\n"),
+  fprintf (file, _("%u bitset_tests, %u cached (%.2f%%)\n"),
           stats->tests, stats->cache_tests,
           stats->tests ? 100.0 * stats->cache_tests / stats->tests : 0);
 
-  fprintf (file, _("%d bitset_lists\n"), stats->lists);
+  fprintf (file, _("%u bitset_lists\n"), stats->lists);
 
   bitset_log_histogram_print (file, name, _("count log histogram\n"),
                              BITSET_LOG_COUNT_BINS, stats->list_counts);
@@ -259,7 +262,7 @@ bitset_stats_print (file, verbose)
   fprintf (file, _("Bitset statistics:\n\n"));
 
   if (bitset_stats_info->runs > 1)
-    fprintf (file, _("Accumulated runs = %d\n"), bitset_stats_info->runs);
+    fprintf (file, _("Accumulated runs = %u\n"), bitset_stats_info->runs);
 
   for (i = 0; i < BITSET_TYPE_NUM; i++)
     bitset_stats_print_1 (file, bitset_type_names[i], 
@@ -430,7 +433,7 @@ bitset_stats_test (src, bitno)
 }
 
 
-static int
+static bitset_bindex
 bitset_stats_size (src)
      bitset src;
 {
@@ -438,7 +441,7 @@ bitset_stats_size (src)
 }
 
 
-static int
+static bitset_bindex
 bitset_stats_count (src)
      bitset src;
 {
@@ -686,7 +689,7 @@ bitset_stats_or_and_cmp (dst, src1, src2
 }
 
 
-static int
+static bitset_bindex
 bitset_stats_list (bset, list, num, next)
      bitset bset;
      bitset_bindex *list;
@@ -728,7 +731,7 @@ bitset_stats_list (bset, list, num, next
 }
 
 
-static int
+static bitset_bindex
 bitset_stats_list_reverse (bset, list, num, next)
      bitset bset;
      bitset_bindex *list;
@@ -793,7 +796,8 @@ bitset_stats_type_get (bset)
 }
 
 
-int bitset_stats_bytes (void)
+size_t
+bitset_stats_bytes (void)
 {
   return sizeof (struct bitset_struct);
 }
@@ -805,7 +809,7 @@ bitset_stats_init (bset, n_bits, type)
      bitset_bindex n_bits;
      enum bitset_type type;
 {
-  unsigned int bytes;
+  size_t bytes;
   bitset sbset;
 
   bset->b.vtable = &bitset_stats_vtable;
diff -pru older/lib/bitset_stats.h bison/lib/bitset_stats.h
--- older/lib/bitset_stats.h    2002-07-02 06:51:26.000000000 -0700
+++ bison/lib/bitset_stats.h    2002-10-02 00:50:39.000000000 -0700
@@ -25,7 +25,7 @@ extern int bitset_stats_enabled;
 
 extern enum bitset_type bitset_stats_type_get PARAMS ((bitset));
 
-extern int bitset_stats_bytes PARAMS ((void));
+extern size_t bitset_stats_bytes PARAMS ((void));
 
 extern bitset bitset_stats_init PARAMS ((bitset, bitset_bindex, 
                                         enum bitset_type));
diff -pru older/lib/bitsetv-print.c bison/lib/bitsetv-print.c
--- older/lib/bitsetv-print.c   2002-05-06 01:42:23.000000000 -0700
+++ bison/lib/bitsetv-print.c   2002-10-02 00:52:50.000000000 -0700
@@ -1,5 +1,5 @@
 /* Bitset vectors.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of Bison.
 
@@ -32,8 +32,8 @@ Software Foundation, 59 Temple Place - S
 void
 bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
 {
-  size_t i, j;
-  size_t hsize = bitset_size (bset[0]);
+  bitset_bindex i, j;
+  bitset_bindex hsize = bitset_size (bset[0]);
 
   /* Title. */
   fprintf (out, "%s BEGIN\n", title);
@@ -45,7 +45,7 @@ bitsetv_matrix_dump (FILE * out, const c
   putc ('\n', out);
   fputs ("   ", out);
   for (i = 0; i < hsize; ++i)
-    fprintf (out, "%d", i % 10);
+    fprintf (out, "%d", (int) (i % 10));
   putc ('\n', out);
 
   /* Bar. */
@@ -57,7 +57,7 @@ bitsetv_matrix_dump (FILE * out, const c
   /* Contents. */
   for (i = 0; bset[i]; ++i)
     {
-      fprintf (out, "%2d|", i);
+      fprintf (out, "%2lu|", (unsigned long) i);
       for (j = 0; j < hsize; ++j)
        fputs (bitset_test (bset[i], j) ? "1" : " ", out);
       fputs ("|\n", out);
diff -pru older/lib/bitsetv.c bison/lib/bitsetv.c
--- older/lib/bitsetv.c 2002-09-30 05:50:49.000000000 -0700
+++ bison/lib/bitsetv.c 2002-10-02 00:54:52.000000000 -0700
@@ -30,17 +30,21 @@ Software Foundation, 59 Temple Place - S
    type TYPE.  */
 bitset *
 bitsetv_alloc (n_vecs, n_bits, type)
-     unsigned int n_vecs;
-     unsigned int n_bits;
+     bitset_bindex n_vecs;
+     bitset_bindex n_bits;
      enum bitset_type type;
 {
-  unsigned int vector_bytes;
-  unsigned int bytes;
+  size_t vector_bytes;
+  size_t bytes;
   bitset *bsetv;
-  unsigned int i;
+  bitset_bindex i;
   
   /* Determine number of bytes for each set.  */
   bytes = bitset_bytes (type, n_bits);
+
+  /* If size calculation overflows, memory is exhausted.  */
+  if (BITSET_SIZE_MAX / (sizeof (bitset) + bytes) <= n_vecs)
+    xalloc_die ();
   
   /* Allocate vector table at head of bitset array.  */
   vector_bytes = (n_vecs + 1) * sizeof (bitset);
@@ -63,8 +67,8 @@ bitsetv_alloc (n_vecs, n_bits, type)
    attribute hints specified by ATTR.  */
 bitset *
 bitsetv_create (n_vecs, n_bits, attr)
-     unsigned int n_vecs;
-     unsigned int n_bits;
+     bitset_bindex n_vecs;
+     bitset_bindex n_bits;
      unsigned int attr;
 {
   enum bitset_type type;
@@ -79,7 +83,7 @@ void
 bitsetv_free (bsetv)
      bitset *bsetv;
 {
-  unsigned int i;
+  bitset_bindex i;
 
   for (i = 0; bsetv[i]; i++)
       BITSET_FREE_ (bsetv[i]);
@@ -92,7 +96,7 @@ void
 bitsetv_zero (bsetv)
      struct bitset_struct **bsetv;
 {
-  unsigned int i;
+  bitset_bindex i;
   
   for (i = 0; bsetv[i]; i++)
     bitset_zero (bsetv[i]);
@@ -104,7 +108,7 @@ void
 bitsetv_ones (bsetv)
      bitset *bsetv;
 {
-  unsigned int i;
+  bitset_bindex i;
   
   for (i = 0; bsetv[i]; i++)
     bitset_ones (bsetv[i]);
@@ -117,8 +121,8 @@ void
 bitsetv_transitive_closure (bsetv)
      bitset *bsetv;
 {
-  unsigned int i;
-  unsigned int j;
+  bitset_bindex i;
+  bitset_bindex j;
 
   for (i = 0; bsetv[i]; i++)
     for (j = 0; bsetv[j]; j++)
@@ -134,7 +138,7 @@ bitsetv_transitive_closure (bsetv)
 void
 bitsetv_reflexive_transitive_closure (bitsetv bsetv)
 {
-  int i;
+  bitset_bindex i;
 
   bitsetv_transitive_closure (bsetv);
   for (i = 0; bsetv[i]; i++)
@@ -150,12 +154,12 @@ bitsetv_dump (file, title, subtitle, bse
      const char *title, *subtitle;
      bitset *bsetv;
 {
-  unsigned int i;
+  bitset_windex i;
   
   fprintf (file, "%s\n", title);
   for (i = 0; bsetv[i]; i++)
     {
-      fprintf (file, "%s %d\n", subtitle, i);
+      fprintf (file, "%s %lu\n", subtitle, (unsigned long) i);
       bitset_dump (file, bsetv[i]);
     }
   
@@ -167,11 +171,11 @@ void
 debug_bitsetv (bsetv)
      bitset *bsetv;
 {
-  unsigned int i;
+  bitset_windex i;
   
   for (i = 0; bsetv[i]; i++)
     {
-      fprintf (stderr, "%d: ", i);
+      fprintf (stderr, "%lu: ", (unsigned long) i);
       debug_bitset (bsetv[i]);
     }
   
diff -pru older/lib/bitsetv.h bison/lib/bitsetv.h
--- older/lib/bitsetv.h 2002-03-04 06:15:01.000000000 -0800
+++ bison/lib/bitsetv.h 2002-10-02 00:55:44.000000000 -0700
@@ -25,12 +25,12 @@ typedef bitset * bitsetv;
 
 /* Create a vector of N_VECS bitsets, each of N_BITS, and of
    type TYPE.  */
-extern bitsetv bitsetv_alloc PARAMS ((unsigned int, unsigned int,
+extern bitsetv bitsetv_alloc PARAMS ((bitset_bindex, bitset_bindex,
                                      enum bitset_type));
 
 /* Create a vector of N_VECS bitsets, each of N_BITS, and with
    attribute hints specified by ATTR.  */
-extern bitsetv bitsetv_create PARAMS ((unsigned int, unsigned int,
+extern bitsetv bitsetv_create PARAMS ((bitset_bindex, bitset_bindex,
                                       unsigned int));
 
 /* Free vector of bitsets.  */
diff -pru older/lib/ebitset.c bison/lib/ebitset.c
--- older/lib/ebitset.c 2002-09-30 05:50:49.000000000 -0700
+++ bison/lib/ebitset.c 2002-10-02 00:57:24.000000000 -0700
@@ -40,7 +40,7 @@
    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.   
 */
@@ -71,7 +71,7 @@ typedef ebitset_elt *ebitset_elts;
 /* 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;
@@ -108,25 +108,25 @@ static struct obstack ebitset_obstack;
 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));
@@ -136,9 +136,9 @@ static int ebitset_and_cmp PARAMS ((bits
 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));
 
@@ -149,10 +149,10 @@ 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) \
@@ -173,14 +173,17 @@ static void ebitset_free PARAMS ((bitset
 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;
@@ -269,7 +272,7 @@ ebitset_elt_free (elt)
 static inline void
 ebitset_elt_remove (bset, eindex)
      bitset bset;
-     unsigned int eindex;
+     bitset_windex eindex;
 {
   ebitset_elts *elts;
   ebitset_elt *elt;
@@ -288,7 +291,7 @@ static inline void
 ebitset_elt_add (bset, elt, eindex)
      bitset bset;
      ebitset_elt *elt;
-     unsigned int eindex;
+     bitset_windex eindex;
 {
   ebitset_elts *elts;
 
@@ -321,7 +324,7 @@ ebitset_elt_find (bset, windex, mode)
 {
   ebitset_elt *elt;
   bitset_windex size;
-  unsigned int eindex;
+  bitset_windex eindex;
   ebitset_elts *elts;
 
   eindex = windex / EBITSET_ELT_WORDS;
@@ -351,7 +354,7 @@ ebitset_elt_find (bset, windex, mode)
     case EBITSET_CREATE:
       if (eindex >= size)
        {
-         unsigned int extra;
+         bitset_windex extra;
 
          extra = eindex - size + 1;
 
@@ -395,13 +398,13 @@ ebitset_elt_last (bset)
 
 
 /* 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;
@@ -567,7 +570,7 @@ ebitset_copy_cmp (dst, src)
 
 
 /* Return size in bits of bitset SRC.  */
-static int
+static bitset_bindex
 ebitset_size (src)
      bitset src;
 {
@@ -639,7 +642,7 @@ ebitset_free (bset)
 /* 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;
@@ -652,7 +655,7 @@ ebitset_list_reverse (bset, list, num, n
   unsigned int bcount;
   bitset_bindex boffset;
   bitset_windex windex;
-  unsigned int eindex;
+  bitset_windex eindex;
   bitset_windex woffset;
   bitset_bindex count;
   bitset_windex size;
@@ -731,7 +734,7 @@ ebitset_list_reverse (bset, list, num, n
 /* 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;
@@ -740,7 +743,7 @@ ebitset_list (bset, list, num, next)
 {
   bitset_bindex bitno;
   bitset_windex windex;
-  unsigned int eindex;
+  bitset_windex eindex;
   bitset_bindex count;
   bitset_windex size;
   ebitset_elt *elt;
@@ -1296,7 +1299,7 @@ struct bitset_vtable ebitset_vtable = {
 
 
 /* Return size of initial structure.  */
-int
+size_t
 ebitset_bytes (n_bits)
      bitset_bindex n_bits ATTRIBUTE_UNUSED;
 {
@@ -1311,7 +1314,7 @@ ebitset_init (bset, n_bits)
      bitset bset;
      bitset_bindex n_bits;
 {
-  unsigned int size;
+  bitset_windex size;
 
   bset->b.vtable = &ebitset_vtable;
 
diff -pru older/lib/ebitset.h bison/lib/ebitset.h
--- older/lib/ebitset.h 2002-07-02 06:51:26.000000000 -0700
+++ bison/lib/ebitset.h 2002-10-02 00:58:11.000000000 -0700
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suit
 
 #include "bbitset.h"
 
-extern int ebitset_bytes PARAMS ((bitset_bindex));
+extern size_t ebitset_bytes PARAMS ((bitset_bindex));
 
 extern bitset ebitset_init PARAMS ((bitset, bitset_bindex));
 
diff -pru older/lib/lbitset.c bison/lib/lbitset.c
--- older/lib/lbitset.c 2002-09-30 05:50:49.000000000 -0700
+++ bison/lib/lbitset.c 2002-10-02 01:00:19.000000000 -0700
@@ -110,11 +110,11 @@ static int lbitset_copy_cmp PARAMS ((bit
 static void lbitset_set PARAMS ((bitset, bitset_bindex));
 static void lbitset_reset PARAMS ((bitset, bitset_bindex));
 static int lbitset_test PARAMS ((bitset, bitset_bindex));
-static int lbitset_size PARAMS ((bitset));
+static bitset_bindex lbitset_size PARAMS ((bitset));
 static int lbitset_op3_cmp PARAMS ((bitset, bitset, bitset, enum bitset_ops));
-static int lbitset_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
-                                bitset_bindex *));
-static int lbitset_list_reverse
+static bitset_bindex lbitset_list PARAMS ((bitset, bitset_bindex *,
+                                          bitset_bindex, bitset_bindex *));
+static bitset_bindex lbitset_list_reverse
 PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *));
 static void lbitset_free PARAMS ((bitset));
 
@@ -417,7 +417,7 @@ lbitset_elt_find (bset, windex, mode)
       return 0;
 
     case LBITSET_CREATE:
-      windex = (windex / (unsigned) LBITSET_ELT_WORDS) * LBITSET_ELT_WORDS;
+      windex -= windex % LBITSET_ELT_WORDS;
 
       elt = lbitset_elt_calloc ();
       elt->index = windex;
@@ -563,7 +563,7 @@ lbitset_copy_cmp (dst, src)
 
 
 /* Return size in bits of bitset SRC.  */
-static int
+static bitset_bindex
 lbitset_size (src)
      bitset src;
 {
@@ -638,7 +638,7 @@ lbitset_free (bset)
 /* 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
 lbitset_list_reverse (bset, list, num, next)
      bitset bset;
      bitset_bindex *list;
@@ -736,7 +736,7 @@ lbitset_list_reverse (bset, list, num, n
 /* 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
 lbitset_list (bset, list, num, next)
      bitset bset;
      bitset_bindex *list;
@@ -954,7 +954,7 @@ static void
 lbitset_ones (dst)
      bitset dst;
 {
-  unsigned int i;
+  bitset_windex i;
   bitset_windex windex;
   lbitset_elt *elt;
 
@@ -985,7 +985,7 @@ lbitset_not (dst, src)
   lbitset_elt *elt;
   lbitset_elt *selt;
   lbitset_elt *delt;
-  unsigned int i;
+  bitset_windex i;
   unsigned int j;
   bitset_windex windex;
 
@@ -1114,8 +1114,8 @@ lbitset_op3_cmp (dst, src1, src2, op)
   LBITSET_HEAD (dst) = 0;
   dst->b.csize = 0;
 
-  windex1 = (selt1) ? selt1->index : BITSET_INDEX_MAX;
-  windex2 = (selt2) ? selt2->index : BITSET_INDEX_MAX;
+  windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
+  windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
 
   while (selt1 || selt2)
     {
@@ -1127,9 +1127,9 @@ lbitset_op3_cmp (dst, src1, src2, op)
          stmp1 = selt1;
          stmp2 = selt2;
          selt1 = selt1->next;
-         windex1 = (selt1) ? selt1->index : BITSET_INDEX_MAX;
+         windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
          selt2 = selt2->next;
-         windex2 = (selt2) ? selt2->index : BITSET_INDEX_MAX;
+         windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
        }
       else if (windex1 < windex2)
        {
@@ -1137,7 +1137,7 @@ lbitset_op3_cmp (dst, src1, src2, op)
          stmp1 = selt1;
          stmp2 = &lbitset_zero_elts[0];
          selt1 = selt1->next;
-         windex1 = (selt1) ? selt1->index : BITSET_INDEX_MAX;
+         windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
        }
       else
        {
@@ -1145,7 +1145,7 @@ lbitset_op3_cmp (dst, src1, src2, op)
          stmp1 = &lbitset_zero_elts[0];
          stmp2 = selt2;
          selt2 = selt2->next;
-         windex2 = (selt2) ? selt2->index : BITSET_INDEX_MAX;
+         windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
        }
 
       /* Find the appropriate element from DST.  Begin by discarding
@@ -1385,7 +1385,7 @@ struct bitset_vtable lbitset_vtable = {
 
 
 /* Return size of initial structure.  */
-int
+size_t
 lbitset_bytes (n_bits)
      bitset_bindex n_bits ATTRIBUTE_UNUSED;
 {
@@ -1429,7 +1429,7 @@ debug_lbitset (bset)
   
   for (elt = LBITSET_HEAD (bset); elt; elt = elt->next)
     {
-      fprintf (stderr, "Elt %d\n", elt->index);
+      fprintf (stderr, "Elt %lu\n", (unsigned long) elt->index);
       for (i = 0; i < LBITSET_ELT_WORDS; i++)
        {
          unsigned int j;
@@ -1437,10 +1437,10 @@ debug_lbitset (bset)
          
          word = elt->words[i];
          
-         fprintf (stderr, "  Word %d:", i);
+         fprintf (stderr, "  Word %u:", i);
          for (j = 0; j < LBITSET_WORD_BITS; j++)
            if ((word & (1 << j)))
-             fprintf (stderr, " %d", j);
+             fprintf (stderr, " %u", j);
          fprintf (stderr, "\n");
        }
     }
diff -pru older/lib/lbitset.h bison/lib/lbitset.h
--- older/lib/lbitset.h 2002-07-02 06:51:26.000000000 -0700
+++ bison/lib/lbitset.h 2002-10-02 01:02:06.000000000 -0700
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suit
 
 #include "bbitset.h"
 
-extern int lbitset_bytes PARAMS ((bitset_bindex));
+extern size_t lbitset_bytes PARAMS ((bitset_bindex));
 
 extern bitset lbitset_init PARAMS ((bitset, bitset_bindex));
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]