#endif
/* Global data */
-bitmap_element bitmap_zero_bits; /* An element of all zero bits. */
-bitmap_element *bitmap_free; /* Freelist of bitmap elements. */
+bitmap_element bitmap_zero_bits; /* An element of all zero bits. */
+static bitmap_element *bitmap_free; /* Freelist of bitmap elements. */
static void bitmap_element_free PARAMS ((bitmap, bitmap_element *));
static bitmap_element *bitmap_element_allocate PARAMS ((void));
static void bitmap_element_link PARAMS ((bitmap, bitmap_element *));
static bitmap_element *bitmap_find_bit PARAMS ((bitmap, unsigned int));
\f
-/* Free a bitmap element */
+/* Free a bitmap element. Since these are allocated off the
+ bitmap_obstack, "free" actually means "put onto the freelist". */
static INLINE void
bitmap_element_free (head, elt)
bitmap_element_allocate ()
{
bitmap_element *element;
-#if BITMAP_ELEMENT_WORDS != 2
- int i;
-#endif
if (bitmap_free != 0)
{
sizeof (bitmap_element));
}
-#if BITMAP_ELEMENT_WORDS == 2
- element->bits[0] = element->bits[1] = 0;
-#else
- for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
- element->bits[i] = 0;
-#endif
+ memset (element->bits, 0, sizeof (element->bits));
return element;
}
head->first = head->current = 0;
}
\f
-/* Copy a bitmap to another bitmap */
+/* Copy a bitmap to another bitmap. */
void
bitmap_copy (to, from)
}
}
-\f
/* Set a single bit in a bitmap. */
void
else
ptr->bits[word_num] |= bit_val;
}
-\f
+
/* Return whether a bit is set within a bitmap. */
int
return (ptr->bits[word_num] >> bit_num) & 1;
}
\f
+/* Return the bit number of the first set bit in the bitmap, or -1
+ if the bitmap is empty. */
int
bitmap_first_set_bit (a)
+ bit_num);
}
+/* Return the bit number of the last set bit in the bitmap, or -1
+ if the bitmap is empty. */
+
int
bitmap_last_set_bit (a)
bitmap a;
if (word & 0xc)
word >>= 2, bit_num += 2;
if (word & 0x2)
- word >>= 1, bit_num += 1;
+ bit_num += 1;
return (ptr->indx * BITMAP_ELEMENT_ALL_BITS
+ word_num * HOST_BITS_PER_WIDE_INT
}
/* Find the appropriate element from TO. Begin by discarding
- elements that we've skipped. */
+ elements that we've skipped. */
while (to_ptr && to_ptr->indx < indx)
{
changed = 1;
}
\f
/* Or into bitmap TO bitmap FROM1 and'ed with the complement of
- bitmap FROM2. */
+ bitmap FROM2. */
void
bitmap_ior_and_compl (to, from1, from2)
fprintf (file, " }\n");
}
}
-\f
+
/* Function to be called from the debugger to print the contents
of a bitmap. */
{
debug_bitmap_file (stdout, head);
}
-\f
+
/* Function to print out the contents of a bitmap. Unlike debug_bitmap_file,
it does not print anything but the bits. */