/* Generic bitsets.
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+ Copyright (C) 2002-2004, 2009-2015 Free Software Foundation, Inc.
+
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _BITSET_H
#define _BITSET_H
#include "obstack.h"
#include <stdio.h>
+#if USE_UNLOCKED_IO
+# include "unlocked-io.h"
+#endif
+
/* Attributes used to select a bitset implementation. */
enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
- BITSET_VARIABLE = 2, /* Bitset size variable. */
- BITSET_DENSE = 4, /* Bitset dense. */
- BITSET_SPARSE = 8, /* Bitset sparse. */
- BITSET_FRUGAL = 16, /* Prefer most compact. */
- BITSET_GREEDY = 32}; /* Prefer fastest at memory expense. */
+ BITSET_VARIABLE = 2, /* Bitset size variable. */
+ BITSET_DENSE = 4, /* Bitset dense. */
+ BITSET_SPARSE = 8, /* Bitset sparse. */
+ BITSET_FRUGAL = 16, /* Prefer most compact. */
+ BITSET_GREEDY = 32}; /* Prefer fastest at memory expense. */
typedef unsigned int bitset_attrs;
{
/* This must be the first member of every other structure that is a
member of this union. */
- struct bbitset_struct b; /* Base bitset data. */
+ struct bbitset_struct b; /* Base bitset data. */
struct abitset_struct
{
struct bbitset_struct b;
- bitset_word words[1]; /* The array of bits. */
+ bitset_word words[1]; /* The array of bits. */
} a;
struct ebitset_struct
{
struct bbitset_struct b;
- bitset_windex size; /* Number of elements. */
- struct ebitset_elt_struct **elts; /* Expanding array of ptrs to elts. */
+ bitset_windex size; /* Number of elements. */
+ struct ebitset_elt_struct **elts; /* Expanding array of ptrs to elts. */
} e;
struct lbitset_struct
{
struct bbitset_struct b;
- struct lbitset_elt_struct *head; /* First element in linked list. */
- struct lbitset_elt_struct *tail; /* Last element in linked list. */
+ struct lbitset_elt_struct *head; /* First element in linked list. */
+ struct lbitset_elt_struct *tail; /* Last element in linked list. */
} l;
struct bitset_stats_struct
struct vbitset_struct
{
struct bbitset_struct b;
- bitset_windex size; /* Allocated size of array. */
+ bitset_windex size; /* Allocated size of array. */
} v;
};
/* Create a bitset of desired type and size using an obstack. The
bitset is zeroed. */
extern bitset bitset_obstack_alloc (struct obstack *bobstack,
- bitset_bindex, enum bitset_type);
+ bitset_bindex, enum bitset_type);
/* Free bitset allocated on obstack. */
extern void bitset_obstack_free (bitset);
printf ("%lu ", (unsigned long int) i);
};
*/
-#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
- for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
- (ITER.num == BITSET_LIST_SIZE) \
- && (ITER.num = bitset_list (BSET, ITER.list, \
- BITSET_LIST_SIZE, &ITER.next));) \
- for (ITER.i = 0; \
- ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
- ITER.i++)
+#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
+ for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
+ (ITER.num == BITSET_LIST_SIZE) \
+ && (ITER.num = bitset_list (BSET, ITER.list, \
+ BITSET_LIST_SIZE, &ITER.next));) \
+ for (ITER.i = 0; \
+ ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
+ ITER.i++)
/* Loop over all elements of BSET, in reverse order starting with
printf ("%lu ", (unsigned long int) i);
};
*/
-#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
- for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
- (ITER.num == BITSET_LIST_SIZE) \
- && (ITER.num = bitset_list_reverse (BSET, ITER.list, \
- BITSET_LIST_SIZE, &ITER.next));) \
- for (ITER.i = 0; \
- ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
- ITER.i++)
+#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
+ for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
+ (ITER.num == BITSET_LIST_SIZE) \
+ && (ITER.num = bitset_list_reverse (BSET, ITER.list, \
+ BITSET_LIST_SIZE, &ITER.next));) \
+ for (ITER.i = 0; \
+ ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
+ ITER.i++)
/* Define set operations in terms of logical operations. */
extern void bitset_stats_disable (void);
/* Read bitset stats file of accummulated stats. */
-void bitset_stats_read (const char *filename);
+void bitset_stats_read (const char *file_name);
/* Write bitset stats file of accummulated stats. */
-void bitset_stats_write (const char *filename);
+void bitset_stats_write (const char *file_name);
/* Dump bitset stats. */
extern void bitset_stats_dump (FILE *);
extern void debug_bitset_stats (void);
#endif /* _BITSET_H */
-