#include "ggc.h"
#include "bitmap.h"
-/* Obstack to allocate bitmap elements from. */
-\f
-#ifndef INLINE
-#ifndef __GNUC__
-#define INLINE
-#else
-#define INLINE __inline__
-#endif
-#endif
-
/* Global data */
bitmap_element bitmap_zero_bits; /* An element of all zero bits. */
bitmap_obstack bitmap_default_obstack; /* The default bitmap obstack. */
\f
/* Add ELEM to the appropriate freelist. */
-static INLINE void
+static inline void
bitmap_elem_to_freelist (bitmap head, bitmap_element *elt)
{
bitmap_obstack *bit_obstack = head->obstack;
/* Free a bitmap element. Since these are allocated off the
bitmap_obstack, "free" actually means "put onto the freelist". */
-static INLINE void
+static inline void
bitmap_element_free (bitmap head, bitmap_element *elt)
{
bitmap_element *next = elt->next;
\f
/* Allocate a bitmap element. The bits are cleared, but nothing else is. */
-static INLINE bitmap_element *
+static inline bitmap_element *
bitmap_element_allocate (bitmap head)
{
bitmap_element *element;
/* Clear a bitmap by freeing the linked list. */
-INLINE void
+inline void
bitmap_clear (bitmap head)
{
bitmap_element *element, *next;
return map;
}
-/* Create a new malloced bitmap. Elements will be allocated from the
- default bitmap obstack. */
-
-bitmap
-bitmap_malloc_alloc (void)
-{
- bitmap map;
-
- map = xmalloc (sizeof (bitmap_head));
- bitmap_initialize (map, &bitmap_default_obstack);
-
- return map;
-}
-
/* Release an obstack allocated bitmap. */
void
bitmap_obstack_free (bitmap map)
{
- bitmap_clear (map);
- map->first = (void *)map->obstack->heads;
- map->obstack->heads = map;
-}
-
-/* Release a malloc allocated bitmap. */
-
-void
-bitmap_malloc_free (bitmap map)
-{
- bitmap_clear (map);
- free (map);
+ if (map)
+ {
+ bitmap_clear (map);
+ map->first = (void *)map->obstack->heads;
+ map->obstack->heads = map;
+ }
}
\f
/* Return nonzero if all bits in an element are zero. */
-static INLINE int
+static inline int
bitmap_element_zerop (bitmap_element *element)
{
#if BITMAP_ELEMENT_WORDS == 2
\f
/* Link the bitmap element into the current bitmap linked list. */
-static INLINE void
+static inline void
bitmap_element_link (bitmap head, bitmap_element *element)
{
unsigned int indx = element->indx;
would hold the bitmap's bit to make eventual allocation
faster. */
-static INLINE bitmap_element *
+static inline bitmap_element *
bitmap_find_bit (bitmap head, unsigned int bit)
{
bitmap_element *element;
|| head->indx == indx)
return head->current;
- if (head->indx > indx)
+ if (head->indx < indx)
+ /* INDX is beyond head->indx. Search from head->current
+ forward. */
+ for (element = head->current;
+ element->next != 0 && element->indx < indx;
+ element = element->next)
+ ;
+
+ else if (head->indx / 2 < indx)
+ /* INDX is less than head->indx and closer to head->indx than to
+ 0. Search from head->current backward. */
for (element = head->current;
element->prev != 0 && element->indx > indx;
element = element->prev)
;
else
- for (element = head->current;
+ /* INDX is less than head->indx and closer to 0 than to
+ head->indx. Search from head->first forward. */
+ for (element = head->first;
element->next != 0 && element->indx < indx;
element = element->next)
;