Compare commits

...
Author SHA1 Message Date
Paul Eggert 7347b2d316 Import of 2003-06-08 libbitset <http://mail.gnu.org/archive/html/bison-patches/2003-06/msg00005.html> 2003-06-07 23:28:20 +00:00
Paul Eggert 58f5a6af40 Import of 2003-06-08 libbitset <http://mail.gnu.org/archive/html/bison-patches/2003-06/msg00005.html> 2003-06-07 00:31:33 +00:00
Paul Eggert 888f3f0178 Import of 2003-06-08 libbitset <http://mail.gnu.org/archive/html/bison-patches/2003-06/msg00005.html> 2003-06-06 22:03:15 +00:00
Paul Eggert 692be7fef0 Import of 2003-06-08 libbitset <http://mail.gnu.org/archive/html/bison-patches/2003-06/msg00005.html> 2003-06-05 10:40:45 +00:00
Paul Eggert 4bfd57ce09 Import of 2003-06-08 libbitset <http://mail.gnu.org/archive/html/bison-patches/2003-06/msg00005.html> 2003-06-05 10:33:45 +00:00
Paul Eggert 964db18ed6 Import of 2003-06-08 libbitset <http://mail.gnu.org/archive/html/bison-patches/2003-06/msg00005.html> 2003-06-02 11:54:30 +00:00
Paul Eggert 598c90ee77 Import of 2003-06-08 libbitset <http://mail.gnu.org/archive/html/bison-patches/2003-06/msg00005.html> 2003-06-02 10:19:35 +00:00
Paul Eggert f7f37a7a0b Import of 2003-06-08 libbitset <http://mail.gnu.org/archive/html/bison-patches/2003-06/msg00005.html> 2003-06-02 10:15:50 +00:00
Paul Eggert 671dc16a4a Import of 2003-06-08 libbitset <http://mail.gnu.org/archive/html/bison-patches/2003-06/msg00005.html> 2003-06-01 05:58:20 +00:00
Paul Eggert b3be630198 Import of 2003-06-08 libbitset <http://mail.gnu.org/archive/html/bison-patches/2003-06/msg00005.html> 2003-06-01 03:37:04 +00:00
Paul Eggert 5aca537f83 Import of 2003-06-08 libbitset <http://mail.gnu.org/archive/html/bison-patches/2003-06/msg00005.html> 2003-06-01 02:47:43 +00:00
16 changed files with 548 additions and 445 deletions
+15 -10
View File
@@ -1,10 +1,10 @@
/* Array bitsets.
Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software: you can redistribute it and/or modify
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -13,9 +13,13 @@
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, see <http://www.gnu.org/licenses/>. */
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "abitset.h"
#include <stddef.h>
@@ -30,13 +34,14 @@
static bitset_bindex
abitset_resize (bitset src, bitset_bindex size)
abitset_resize (bitset src ATTRIBUTE_UNUSED,
bitset_bindex size ATTRIBUTE_UNUSED)
{
/* These bitsets have a fixed size. */
if (BITSET_SIZE_ (src) != size)
abort ();
if (BITSET_SIZE_ (src) == size)
return size;
/* These bitsets have a fixed size. */
abort ();
}
/* Find list of up to NUM bits set in BSET starting from and including
+14 -13
View File
@@ -1,27 +1,28 @@
/* Functions to support abitsets.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
Copyright (C) 2002 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
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 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 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, see <http://www.gnu.org/licenses/>. */
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _ABITSET_H
#define _ABITSET_H
#include "bitset.h"
extern size_t abitset_bytes (bitset_bindex);
extern size_t abitset_bytes PARAMS ((bitset_bindex));
extern bitset abitset_init (bitset, bitset_bindex);
extern bitset abitset_init PARAMS ((bitset, bitset_bindex));
#endif
+65 -62
View File
@@ -1,28 +1,30 @@
/* Base bitset stuff.
Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
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 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 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, see <http://www.gnu.org/licenses/>. */
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _BBITSET_H
#define _BBITSET_H
#include "config.h"
#include "libiberty.h"
#include <stdbool.h>
#include <limits.h>
#include <stddef.h>
#include <sys/types.h>
/* Currently we support five flavours of bitsets:
BITSET_ARRAY: Array of bits (fixed size, fast for dense bitsets).
@@ -47,8 +49,8 @@ extern const char * const bitset_type_names[];
enum bitset_alloc_type {BITSET_MALLOC, BITSET_OBALLOC};
/* Data type used to store a word of bits. */
typedef unsigned long int bitset_word;
#define BITSET_WORD_BITS ((unsigned int) (CHAR_BIT * sizeof (bitset_word)))
typedef unsigned long bitset_word;
#define BITSET_WORD_BITS ((unsigned) (CHAR_BIT * sizeof (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
@@ -110,45 +112,46 @@ typedef union bitset_union *bitset;
/* The contents of this structure should be considered private. */
struct bitset_vtable
{
void (*set) (bitset, bitset_bindex);
void (*reset) (bitset, bitset_bindex);
bool (*toggle) (bitset, bitset_bindex);
bool (*test) (bitset, bitset_bindex);
bitset_bindex (*resize) (bitset, bitset_bindex);
bitset_bindex (*size) (bitset);
bitset_bindex (*count) (bitset);
void (*set) PARAMS ((bitset, bitset_bindex));
void (*reset) PARAMS ((bitset, bitset_bindex));
bool (*toggle) PARAMS ((bitset, bitset_bindex));
bool (*test) PARAMS ((bitset, bitset_bindex));
bitset_bindex (*resize) PARAMS ((bitset, bitset_bindex));
bitset_bindex (*size) PARAMS ((bitset));
bitset_bindex (*count) PARAMS ((bitset));
bool (*empty_p) (bitset);
void (*ones) (bitset);
void (*zero) (bitset);
bool (*empty_p) PARAMS ((bitset));
void (*ones) PARAMS ((bitset));
void (*zero) PARAMS ((bitset));
void (*copy) (bitset, bitset);
bool (*disjoint_p) (bitset, bitset);
bool (*equal_p) (bitset, bitset);
void (*not_) (bitset, bitset);
bool (*subset_p) (bitset, bitset);
void (*copy) PARAMS ((bitset, bitset));
bool (*disjoint_p) PARAMS ((bitset, bitset));
bool (*equal_p) PARAMS ((bitset, bitset));
void (*not) PARAMS ((bitset, bitset));
bool (*subset_p) PARAMS ((bitset, bitset));
void (*and_) (bitset, bitset, bitset);
bool (*and_cmp) (bitset, bitset, bitset);
void (*andn) (bitset, bitset, bitset);
bool (*andn_cmp) (bitset, bitset, bitset);
void (*or_) (bitset, bitset, bitset);
bool (*or_cmp) (bitset, bitset, bitset);
void (*xor_) (bitset, bitset, bitset);
bool (*xor_cmp) (bitset, bitset, bitset);
void (*and) PARAMS ((bitset, bitset, bitset));
bool (*and_cmp) PARAMS ((bitset, bitset, bitset));
void (*andn) PARAMS ((bitset, bitset, bitset));
bool (*andn_cmp) PARAMS ((bitset, bitset, bitset));
void (*or) PARAMS ((bitset, bitset, bitset));
bool (*or_cmp) PARAMS ((bitset, bitset, bitset));
void (*xor) PARAMS ((bitset, bitset, bitset));
bool (*xor_cmp) PARAMS ((bitset, bitset, bitset));
void (*and_or) (bitset, bitset, bitset, bitset);
bool (*and_or_cmp) (bitset, bitset, bitset, bitset);
void (*andn_or) (bitset, bitset, bitset, bitset);
bool (*andn_or_cmp) (bitset, bitset, bitset, bitset);
void (*or_and) (bitset, bitset, bitset, bitset);
bool (*or_and_cmp) (bitset, bitset, bitset, bitset);
void (*and_or) PARAMS ((bitset, bitset, bitset, bitset));
bool (*and_or_cmp) PARAMS ((bitset, bitset, bitset, bitset));
void (*andn_or) PARAMS ((bitset, bitset, bitset, bitset));
bool (*andn_or_cmp) PARAMS ((bitset, bitset, bitset, bitset));
void (*or_and) PARAMS ((bitset, bitset, bitset, bitset));
bool (*or_and_cmp) PARAMS ((bitset, bitset, bitset, bitset));
bitset_bindex (*list) (bitset, bitset_bindex *, bitset_bindex,
bitset_bindex *);
bitset_bindex (*list_reverse) (bitset, bitset_bindex *, bitset_bindex,
bitset_bindex *);
void (*free) (bitset);
bitset_bindex (*list) PARAMS ((bitset, bitset_bindex *,
bitset_bindex, bitset_bindex *));
bitset_bindex (*list_reverse) PARAMS ((bitset,
bitset_bindex *, bitset_bindex,
bitset_bindex *));
void (*free) PARAMS ((bitset));
enum bitset_type type;
};
@@ -217,14 +220,14 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
#define BITSET_EQUAL_P_(DST, SRC) (SRC)->b.vtable->equal_p (DST, SRC)
/* DST = ~SRC. */
#define BITSET_NOT_(DST, SRC) (SRC)->b.vtable->not_ (DST, SRC)
#define BITSET_NOT_(DST, SRC) (SRC)->b.vtable->not (DST, SRC)
/* Return DST == DST | SRC. */
#define BITSET_SUBSET_P_(DST, SRC) (SRC)->b.vtable->subset_p (DST, SRC)
/* DST = SRC1 & SRC2. */
#define BITSET_AND_(DST, SRC1, SRC2) (SRC1)->b.vtable->and_ (DST, SRC1, SRC2)
#define BITSET_AND_(DST, SRC1, SRC2) (SRC1)->b.vtable->and (DST, SRC1, SRC2)
#define BITSET_AND_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->and_cmp (DST, SRC1, SRC2)
/* DST = SRC1 & ~SRC2. */
@@ -232,11 +235,11 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
#define BITSET_ANDN_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->andn_cmp (DST, SRC1, SRC2)
/* DST = SRC1 | SRC2. */
#define BITSET_OR_(DST, SRC1, SRC2) (SRC1)->b.vtable->or_ (DST, SRC1, SRC2)
#define BITSET_OR_(DST, SRC1, SRC2) (SRC1)->b.vtable->or (DST, SRC1, SRC2)
#define BITSET_OR_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->or_cmp (DST, SRC1, SRC2)
/* DST = SRC1 ^ SRC2. */
#define BITSET_XOR_(DST, SRC1, SRC2) (SRC1)->b.vtable->xor_ (DST, SRC1, SRC2)
#define BITSET_XOR_(DST, SRC1, SRC2) (SRC1)->b.vtable->xor (DST, SRC1, SRC2)
#define BITSET_XOR_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->xor_cmp (DST, SRC1, SRC2)
@@ -278,24 +281,24 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
/* Private functions for bitset implementations. */
extern bool bitset_toggle_ (bitset, bitset_bindex);
extern bool bitset_toggle_ PARAMS ((bitset, bitset_bindex));
extern bitset_bindex bitset_count_ (bitset);
extern bitset_bindex bitset_count_ PARAMS ((bitset));
extern bitset_bindex bitset_size_ (bitset);
extern bitset_bindex bitset_size_ PARAMS ((bitset));
extern bool bitset_copy_ (bitset, bitset);
extern bool bitset_copy_ PARAMS ((bitset, bitset));
extern void bitset_and_or_ (bitset, bitset, bitset, bitset);
extern void bitset_and_or_ PARAMS ((bitset, bitset, bitset, bitset));
extern bool bitset_and_or_cmp_ (bitset, bitset, bitset, bitset);
extern bool bitset_and_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
extern void bitset_andn_or_ (bitset, bitset, bitset, bitset);
extern void bitset_andn_or_ PARAMS ((bitset, bitset, bitset, bitset));
extern bool bitset_andn_or_cmp_ (bitset, bitset, bitset, bitset);
extern bool bitset_andn_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
extern void bitset_or_and_ (bitset, bitset, bitset, bitset);
extern void bitset_or_and_ PARAMS ((bitset, bitset, bitset, bitset));
extern bool bitset_or_and_cmp_ (bitset, bitset, bitset, bitset);
extern bool bitset_or_and_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
#endif /* _BBITSET_H */
+21 -19
View File
@@ -1,10 +1,10 @@
/* General bitsets.
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software: you can redistribute it and/or modify
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -13,14 +13,16 @@
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, see <http://www.gnu.org/licenses/>. */
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <config.h>
#include "bitset.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "bitset.h"
#include "abitset.h"
#include "lbitset.h"
#include "ebitset.h"
@@ -43,9 +45,6 @@ bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
switch (type)
{
default:
abort ();
case BITSET_ARRAY:
bytes = abitset_bytes (n_bits);
break;
@@ -61,6 +60,9 @@ bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
case BITSET_VARRAY:
bytes = vbitset_bytes (n_bits);
break;
default:
abort ();
}
return bytes;
@@ -76,9 +78,6 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
switch (type)
{
default:
abort ();
case BITSET_ARRAY:
return abitset_init (bset, n_bits);
@@ -90,6 +89,9 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
case BITSET_VARRAY:
return vbitset_init (bset, n_bits);
default:
abort ();
}
}
@@ -136,7 +138,7 @@ bitset_alloc (bitset_bindex n_bits, enum bitset_type type)
bytes = bitset_bytes (type, n_bits);
bset = xcalloc (1, bytes);
bset = (bitset) xcalloc (1, bytes);
/* The cache is disabled until some elements are allocated. If we
have variable length arrays, then we may need to allocate a dummy
@@ -294,7 +296,7 @@ bitset_print (FILE *file, bitset bset, bool verbose)
if (verbose)
fprintf (file, "n_bits = %lu, set = {",
(unsigned long int) bitset_size (bset));
(unsigned long) bitset_size (bset));
pos = 30;
BITSET_FOR_EACH (iter, bset, i, 0)
@@ -305,7 +307,7 @@ bitset_print (FILE *file, bitset bset, bool verbose)
pos = 0;
}
fprintf (file, "%lu ", (unsigned long int) i);
fprintf (file, "%d ", i);
pos += 1 + (i >= 10) + (i >= 100);
};
@@ -419,9 +421,6 @@ bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
switch (op)
{
default:
abort ();
case BITSET_OP_OR_AND:
bitset_or (tmp, src1, src2);
changed = bitset_and_cmp (dst, src3, tmp);
@@ -436,6 +435,9 @@ bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
bitset_andn (tmp, src1, src2);
changed = bitset_or_cmp (dst, src3, tmp);
break;
default:
abort ();
}
bitset_free (tmp);
+58 -48
View File
@@ -1,19 +1,20 @@
/* Generic bitsets.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
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 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 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, see <http://www.gnu.org/licenses/>. */
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _BITSET_H
#define _BITSET_H
@@ -22,12 +23,18 @@
Only use the functions and macros defined in this file. */
#include "bbitset.h"
#include "obstack.h"
#include <stdio.h>
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
/* obstack.h tries to be portable to K&R compilers, but its
__INT_TO_PTR macro generates diagnostics on compilers like Tru64 cc
that define __STDC__ to 0 when not in strict ANSI mode. The bitset
code assumes C89 or later, so it can avoid these glitches by
defining __INT_TO_PTR appropriately for C89 or later. */
#ifndef __INT_TO_PTR
# define __INT_TO_PTR(P) ((void *) ((P) + (char *) 0))
#endif
#include "obstack.h"
#include <stdio.h>
/* Attributes used to select a bitset implementation. */
enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
@@ -96,37 +103,38 @@ typedef struct
/* Return bytes required for bitset of desired type and size. */
extern size_t bitset_bytes (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 (bitset, bitset_bindex, enum bitset_type);
extern bitset bitset_init PARAMS ((bitset, bitset_bindex, enum bitset_type));
/* Select an implementation type based on the desired bitset size
and attributes. */
extern enum bitset_type bitset_type_choose (bitset_bindex, bitset_attrs);
extern enum bitset_type bitset_type_choose PARAMS ((bitset_bindex,
bitset_attrs));
/* Create a bitset of desired type and size. The bitset is zeroed. */
extern bitset bitset_alloc (bitset_bindex, enum bitset_type);
extern bitset bitset_alloc PARAMS ((bitset_bindex, enum bitset_type));
/* Free bitset. */
extern void bitset_free (bitset);
extern void bitset_free PARAMS ((bitset));
/* 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);
extern bitset bitset_obstack_alloc PARAMS ((struct obstack *bobstack,
bitset_bindex, enum bitset_type));
/* Free bitset allocated on obstack. */
extern void bitset_obstack_free (bitset);
extern void bitset_obstack_free PARAMS ((bitset));
/* Create a bitset of desired size and attributes. The bitset is zeroed. */
extern bitset bitset_create (bitset_bindex, bitset_attrs);
extern bitset bitset_create PARAMS ((bitset_bindex, bitset_attrs));
/* Return bitset type. */
extern enum bitset_type bitset_type_get (bitset);
extern enum bitset_type bitset_type_get PARAMS ((bitset));
/* Return bitset type name. */
extern const char *bitset_type_name_get (bitset);
extern const char *bitset_type_name_get PARAMS ((bitset));
/* Set bit BITNO in bitset BSET. */
@@ -178,7 +186,7 @@ bitset_test (bitset bset, bitset_bindex bitno)
#define bitset_size(SRC) BITSET_SIZE_ (SRC)
/* Change size of bitset. */
extern void bitset_resize (bitset, bitset_bindex);
extern void bitset_resize PARAMS ((bitset, bitset_bindex));
/* Return number of bits set in bitset SRC. */
#define bitset_count(SRC) BITSET_COUNT_ (SRC)
@@ -278,36 +286,37 @@ extern void bitset_resize (bitset, bitset_bindex);
BITSET_LIST_REVERSE_ (BSET, LIST, NUM, NEXT)
/* Return true if both bitsets are of the same type and size. */
extern bool bitset_compatible_p (bitset bset1, bitset bset2);
extern bool
bitset_compatible_p (bitset bset1, bitset bset2);
/* Find next set bit from the given bit index. */
extern bitset_bindex bitset_next (bitset, bitset_bindex);
extern bitset_bindex bitset_next PARAMS ((bitset, bitset_bindex));
/* Find previous set bit from the given bit index. */
extern bitset_bindex bitset_prev (bitset, bitset_bindex);
extern bitset_bindex bitset_prev PARAMS ((bitset, bitset_bindex));
/* Find first set bit. */
extern bitset_bindex bitset_first (bitset);
extern bitset_bindex bitset_first PARAMS ((bitset));
/* Find last set bit. */
extern bitset_bindex bitset_last (bitset);
extern bitset_bindex bitset_last PARAMS ((bitset));
/* Return nonzero if this is the only set bit. */
extern bool bitset_only_set_p (bitset, bitset_bindex);
extern bool bitset_only_set_p PARAMS ((bitset, bitset_bindex));
/* Dump bitset. */
extern void bitset_dump (FILE *, bitset);
extern void bitset_dump PARAMS ((FILE *, bitset));
/* Loop over all elements of BSET, starting with MIN, setting INDEX
to the index of each set bit. For example, the following will print
the bits set in a bitset:
bitset_bindex i;
bitset_bindex index;
bitset_iterator iter;
BITSET_FOR_EACH (iter, src, i, 0)
BITSET_FOR_EACH (iter, src, index, 0)
{
printf ("%lu ", (unsigned long int) i);
printf ("%ld ", index);
};
*/
#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
@@ -324,12 +333,12 @@ extern void bitset_dump (FILE *, bitset);
MIN, setting INDEX to the index of each set bit. For example, the
following will print the bits set in a bitset in reverse order:
bitset_bindex i;
bitset_bindex index;
bitset_iterator iter;
BITSET_FOR_EACH_REVERSE (iter, src, i, 0)
BITSET_FOR_EACH_REVERSE (iter, src, index, 0)
{
printf ("%lu ", (unsigned long int) i);
printf ("%ld ", index);
};
*/
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
@@ -365,27 +374,28 @@ extern void bitset_dump (FILE *, bitset);
/* Release any memory tied up with bitsets. */
extern void bitset_release_memory (void);
extern void bitset_release_memory PARAMS ((void));
/* Enable bitset stats gathering. */
extern void bitset_stats_enable (void);
extern void bitset_stats_enable PARAMS ((void));
/* Disable bitset stats gathering. */
extern void bitset_stats_disable (void);
extern void bitset_stats_disable PARAMS ((void));
/* Read bitset stats file of accummulated stats. */
void bitset_stats_read (const char *file_name);
void bitset_stats_read PARAMS ((const char *filename));
/* Write bitset stats file of accummulated stats. */
void bitset_stats_write (const char *file_name);
void bitset_stats_write PARAMS ((const char *filename));
/* Dump bitset stats. */
extern void bitset_stats_dump (FILE *);
extern void bitset_stats_dump PARAMS ((FILE *));
/* Function to debug bitset from debugger. */
extern void debug_bitset (bitset);
extern void debug_bitset PARAMS ((bitset));
/* Function to debug bitset stats from debugger. */
extern void debug_bitset_stats (void);
extern void debug_bitset_stats PARAMS ((void));
#endif /* _BITSET_H */
+33 -25
View File
@@ -1,10 +1,10 @@
/* Bitset statistics.
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2002 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software: you can redistribute it and/or modify
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -13,30 +13,38 @@
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, see <http://www.gnu.org/licenses/>. */
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* This file is a wrapper bitset implementation for the other bitset
implementations. It provides bitset compatibility checking and
statistics gathering without having to instrument the bitset
implementations. When statistics gathering is enabled, the bitset
operations get vectored through here and we then call the appropriate
routines. */
routines.
*/
#include <config.h>
#include "bitset_stats.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "bbitset.h"
#include "abitset.h"
#include "ebitset.h"
#include "lbitset.h"
#include "vbitset.h"
#include "bitset_stats.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifdef HAVE_GETTEXT_H
#include "gettext.h"
#define _(Msgid) gettext (Msgid)
#else
#define _(Msgid) Msgid
#endif
/* Configuration macros. */
#define BITSET_STATS_FILE "bitset.dat"
@@ -156,8 +164,8 @@ bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
for (; i < n_bins; i++)
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
1UL << (i - 1),
(1UL << i) - 1,
(unsigned long) 1 << (i - 1),
((unsigned long) 1 << i) - 1,
bins[i],
(100.0 * bins[i]) / total);
}
@@ -237,17 +245,17 @@ bitset_stats_disable (void)
/* Read bitset statistics file. */
void
bitset_stats_read (const char *file_name)
bitset_stats_read (const char *filename)
{
FILE *file;
if (!bitset_stats_info)
return;
if (!file_name)
file_name = BITSET_STATS_FILE;
if (!filename)
filename = BITSET_STATS_FILE;
file = fopen (file_name, "r");
file = fopen (filename, "r");
if (file)
{
if (fread (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
@@ -267,17 +275,17 @@ bitset_stats_read (const char *file_name)
/* Write bitset statistics file. */
void
bitset_stats_write (const char *file_name)
bitset_stats_write (const char *filename)
{
FILE *file;
if (!bitset_stats_info)
return;
if (!file_name)
file_name = BITSET_STATS_FILE;
if (!filename)
filename = BITSET_STATS_FILE;
file = fopen (file_name, "w");
file = fopen (filename, "w");
if (file)
{
if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
@@ -692,32 +700,32 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
we are a wrapper over. */
switch (type)
{
default:
abort ();
case BITSET_ARRAY:
bytes = abitset_bytes (n_bits);
sbset = xcalloc (1, bytes);
sbset = (bitset) xcalloc (1, bytes);
abitset_init (sbset, n_bits);
break;
case BITSET_LIST:
bytes = lbitset_bytes (n_bits);
sbset = xcalloc (1, bytes);
sbset = (bitset) xcalloc (1, bytes);
lbitset_init (sbset, n_bits);
break;
case BITSET_TABLE:
bytes = ebitset_bytes (n_bits);
sbset = xcalloc (1, bytes);
sbset = (bitset) xcalloc (1, bytes);
ebitset_init (sbset, n_bits);
break;
case BITSET_VARRAY:
bytes = vbitset_bytes (n_bits);
sbset = xcalloc (1, bytes);
sbset = (bitset) xcalloc (1, bytes);
vbitset_init (sbset, n_bits);
break;
default:
abort ();
}
bset->s.bset = sbset;
+16 -14
View File
@@ -1,19 +1,20 @@
/* Functions to support bitset statistics.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
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 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 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, see <http://www.gnu.org/licenses/>. */
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _BITSET_STATS_H
#define _BITSET_STATS_H
@@ -22,10 +23,11 @@
extern bool bitset_stats_enabled;
extern enum bitset_type bitset_stats_type_get (bitset);
extern enum bitset_type bitset_stats_type_get PARAMS ((bitset));
extern size_t bitset_stats_bytes (void);
extern size_t bitset_stats_bytes PARAMS ((void));
extern bitset bitset_stats_init (bitset, bitset_bindex, enum bitset_type);
extern bitset bitset_stats_init PARAMS ((bitset, bitset_bindex,
enum bitset_type));
#endif
+21 -16
View File
@@ -1,24 +1,29 @@
/* Bitset vectors.
Copyright (C) 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
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 file is part of GCC.
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.
GCC 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, or (at your option) any later
version.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
GCC 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.
#include <config.h>
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#include "bitsetv.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include "bitsetv.h"
/* Create a vector of N_VECS bitsets, each of N_BITS, and of
@@ -42,7 +47,7 @@ bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
/* Allocate vector table at head of bitset array. */
vector_bytes = (n_vecs + 1) * sizeof (bitset) + bytes - 1;
vector_bytes -= vector_bytes % bytes;
bsetv = xcalloc (1, vector_bytes + bytes * n_vecs);
bsetv = (bitset *) xcalloc (1, vector_bytes + bytes * n_vecs);
for (i = 0; i < n_vecs; i++)
{
@@ -144,7 +149,7 @@ bitsetv_dump (FILE *file, char const *title, char const *subtitle,
fprintf (file, "%s\n", title);
for (i = 0; bsetv[i]; i++)
{
fprintf (file, "%s %lu\n", subtitle, (unsigned long int) i);
fprintf (file, "%s %lu\n", subtitle, (unsigned long) i);
bitset_dump (file, bsetv[i]);
}
@@ -159,7 +164,7 @@ debug_bitsetv (bitsetv bsetv)
for (i = 0; bsetv[i]; i++)
{
fprintf (stderr, "%lu: ", (unsigned long int) i);
fprintf (stderr, "%lu: ", (unsigned long) i);
debug_bitset (bsetv[i]);
}
+24 -20
View File
@@ -1,19 +1,20 @@
/* Bitset vectors.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
Copyright (C) 2002 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
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 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 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, see <http://www.gnu.org/licenses/>. */
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _BITSETV_H
#define _BITSETV_H
@@ -24,35 +25,38 @@ typedef bitset * bitsetv;
/* Create a vector of N_VECS bitsets, each of N_BITS, and of
type TYPE. */
extern bitsetv bitsetv_alloc (bitset_bindex, bitset_bindex, enum bitset_type);
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 (bitset_bindex, bitset_bindex, unsigned int);
extern bitsetv bitsetv_create PARAMS ((bitset_bindex, bitset_bindex,
unsigned int));
/* Free vector of bitsets. */
extern void bitsetv_free (bitsetv);
extern void bitsetv_free PARAMS ((bitsetv));
/* Zero vector of bitsets. */
extern void bitsetv_zero (bitsetv);
extern void bitsetv_zero PARAMS ((bitsetv));
/* Set vector of bitsets. */
extern void bitsetv_ones (bitsetv);
extern void bitsetv_ones PARAMS ((bitsetv));
/* Given a vector BSETV of N bitsets of size N, modify its contents to
be the transitive closure of what was given. */
extern void bitsetv_transitive_closure (bitsetv);
extern void bitsetv_transitive_closure PARAMS ((bitsetv));
/* Given a vector BSETV of N bitsets of size N, modify its contents to
be the reflexive transitive closure of what was given. This is
the same as transitive closure but with all bits on the diagonal
of the bit matrix set. */
extern void bitsetv_reflexive_transitive_closure (bitsetv);
extern void bitsetv_reflexive_transitive_closure PARAMS ((bitsetv));
/* Dump vector of bitsets. */
extern void bitsetv_dump (FILE *, const char *, const char *, bitsetv);
extern void bitsetv_dump PARAMS ((FILE *, const char *,
const char *, bitsetv));
/* Function to debug vector of bitsets from debugger. */
extern void debug_bitsetv (bitsetv);
extern void debug_bitsetv PARAMS ((bitsetv));
#endif /* _BITSETV_H */
+26 -18
View File
@@ -1,10 +1,10 @@
/* Functions to support expandable bitsets.
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software: you can redistribute it and/or modify
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -13,12 +13,15 @@
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, see <http://www.gnu.org/licenses/>. */
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ebitset.h"
#include "obstack.h"
#include <stdlib.h>
#include <string.h>
@@ -49,7 +52,7 @@
/* Number of bits stored in each element. */
#define EBITSET_ELT_BITS \
((unsigned int) (EBITSET_ELT_WORDS * BITSET_WORD_BITS))
((unsigned) (EBITSET_ELT_WORDS * BITSET_WORD_BITS))
/* Ebitset element. We use an array of bits. */
typedef struct ebitset_elt_struct
@@ -112,13 +115,15 @@ static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
((BSET)->b.cindex = (EINDEX) * EBITSET_ELT_WORDS, \
(BSET)->b.cdata = EBITSET_WORDS (EBITSET_ELTS (BSET) [EINDEX]))
#undef min
#undef max
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
static bitset_bindex
ebitset_resize (bitset src, bitset_bindex n_bits)
ebitset_resize (src, n_bits)
bitset src;
bitset_bindex n_bits;
{
bitset_windex oldsize;
bitset_windex newsize;
@@ -207,13 +212,15 @@ ebitset_elt_alloc (void)
#define OBSTACK_CHUNK_FREE free
#endif
#if ! defined __GNUC__ || __GNUC__ < 2
#if !defined(__GNUC__) || (__GNUC__ < 2)
#define __alignof__(type) 0
#endif
obstack_specify_allocation (&ebitset_obstack, OBSTACK_CHUNK_SIZE,
__alignof__ (ebitset_elt),
(void *(*)PARAMS ((long)))
OBSTACK_CHUNK_ALLOC,
(void (*)PARAMS ((void *)))
OBSTACK_CHUNK_FREE);
}
@@ -319,9 +326,6 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
switch (mode)
{
default:
abort ();
case EBITSET_FIND:
return 0;
@@ -337,6 +341,9 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
case EBITSET_SUBST:
return &ebitset_zero_elts[0];
default:
abort ();
}
}
@@ -831,7 +838,8 @@ ebitset_list (bitset bset, bitset_bindex *list,
/* Ensure that any unused bits within the last element are clear. */
static inline void
ebitset_unused_clear (bitset dst)
ebitset_unused_clear (dst)
bitset dst;
{
unsigned int last_bit;
bitset_bindex n_bits;
@@ -1087,9 +1095,6 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
dstp = EBITSET_WORDS (delt);
switch (op)
{
default:
abort ();
case BITSET_OP_OR:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
@@ -1141,6 +1146,9 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
}
}
break;
default:
abort ();
}
if (!ebitset_elt_zero_p (delt))
+15 -14
View File
@@ -1,29 +1,30 @@
/* Functions to support ebitsets.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
Copyright (C) 2002 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
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 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 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, see <http://www.gnu.org/licenses/>. */
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _EBITSET_H
#define _EBITSET_H
#include "bitset.h"
extern size_t ebitset_bytes (bitset_bindex);
extern size_t ebitset_bytes PARAMS ((bitset_bindex));
extern bitset ebitset_init (bitset, bitset_bindex);
extern bitset ebitset_init PARAMS ((bitset, bitset_bindex));
extern void ebitset_release_memory (void);
extern void ebitset_release_memory PARAMS ((void));
#endif
+23 -17
View File
@@ -1,10 +1,10 @@
/* Functions to support link list bitsets.
Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software: you can redistribute it and/or modify
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -13,12 +13,15 @@
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, see <http://www.gnu.org/licenses/>. */
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "lbitset.h"
#include "obstack.h"
#include <stddef.h>
#include <stdlib.h>
@@ -51,7 +54,7 @@ typedef bitset_word lbitset_word;
/* Number of bits stored in each element. */
#define LBITSET_ELT_BITS \
((unsigned int) (LBITSET_ELT_WORDS * LBITSET_WORD_BITS))
((unsigned) (LBITSET_ELT_WORDS * LBITSET_WORD_BITS))
/* Lbitset element. We use an array of bits for each element.
These are linked together in a doubly-linked list. */
@@ -75,7 +78,7 @@ static struct obstack lbitset_obstack;
static bool lbitset_obstack_init = false;
static lbitset_elt *lbitset_free_list; /* Free list of bitset elements. */
extern void debug_lbitset (bitset);
extern void debug_lbitset PARAMS ((bitset));
#define LBITSET_CURRENT1(X) \
((lbitset_elt *) (void *) ((char *) (X) - offsetof (lbitset_elt, words)))
@@ -118,13 +121,15 @@ lbitset_elt_alloc (void)
#define OBSTACK_CHUNK_FREE free
#endif
#if ! defined __GNUC__ || __GNUC__ < 2
#if !defined(__GNUC__) || (__GNUC__ < 2)
#define __alignof__(type) 0
#endif
obstack_specify_allocation (&lbitset_obstack, OBSTACK_CHUNK_SIZE,
__alignof__ (lbitset_elt),
(void *(*)PARAMS ((long)))
OBSTACK_CHUNK_ALLOC,
(void (*)PARAMS ((void *)))
OBSTACK_CHUNK_FREE);
}
@@ -360,9 +365,6 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
switch (mode)
{
default:
abort ();
case LBITSET_FIND:
return 0;
@@ -376,6 +378,9 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
case LBITSET_SUBST:
return &lbitset_zero_elts[0];
default:
abort ();
}
}
@@ -878,7 +883,8 @@ lbitset_empty_p (bitset dst)
/* Ensure that any unused bits within the last element are clear. */
static inline void
lbitset_unused_clear (bitset dst)
lbitset_unused_clear (dst)
bitset dst;
{
unsigned int last_bit;
bitset_bindex n_bits;
@@ -1114,9 +1120,6 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
dstp = dtmp->words;
switch (op)
{
default:
abort ();
case BITSET_OP_OR:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
@@ -1168,6 +1171,9 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
}
}
break;
default:
abort ();
}
if (!lbitset_elt_zero_p (dtmp))
@@ -1385,7 +1391,7 @@ debug_lbitset (bitset bset)
for (elt = LBITSET_HEAD (bset); elt; elt = elt->next)
{
fprintf (stderr, "Elt %lu\n", (unsigned long int) elt->index);
fprintf (stderr, "Elt %lu\n", (unsigned long) elt->index);
for (i = 0; i < LBITSET_ELT_WORDS; i++)
{
unsigned int j;
+15 -14
View File
@@ -1,29 +1,30 @@
/* Functions to support lbitsets.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
Copyright (C) 2002 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
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 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 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, see <http://www.gnu.org/licenses/>. */
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _LBITSET_H
#define _LBITSET_H
#include "bitset.h"
extern size_t lbitset_bytes (bitset_bindex);
extern size_t lbitset_bytes PARAMS ((bitset_bindex));
extern bitset lbitset_init (bitset, bitset_bindex);
extern bitset lbitset_init PARAMS ((bitset, bitset_bindex));
extern void lbitset_release_memory (void);
extern void lbitset_release_memory PARAMS ((void));
#endif
+7 -30
View File
@@ -1,35 +1,12 @@
/* Fake libiberty.h for Bison.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
/* Dummy libiberty header file. */
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.
#define PARAMS(X) X
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.
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#define xmalloc malloc
#define xcalloc calloc
#define xrealloc realloc
#define xalloc_die()
/* Bison depends on libiberty's implementation of bitsets, which
requires a `libiberty.h' file. This file provides the minimum
services. */
#ifndef BISON_LIBIBERTY_H_
# define BISON_LIBIBERTY_H_ 1
# ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
# define __attribute__(x)
# endif
# endif
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
# include "xalloc.h"
#endif /* ! BISON_LIBIBERTY_H_ */
+110 -41
View File
@@ -1,10 +1,10 @@
/* Variable array bitsets.
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software: you can redistribute it and/or modify
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -13,12 +13,15 @@
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, see <http://www.gnu.org/licenses/>. */
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "vbitset.h"
#include <stdlib.h>
#include <string.h>
@@ -30,28 +33,31 @@
has the same size.
*/
static void vbitset_unused_clear (bitset);
static void vbitset_unused_clear PARAMS ((bitset));
static void vbitset_set (bitset, bitset_bindex);
static void vbitset_reset (bitset, bitset_bindex);
static bool vbitset_test (bitset, bitset_bindex);
static bitset_bindex vbitset_list (bitset, bitset_bindex *,
bitset_bindex, bitset_bindex *);
static bitset_bindex vbitset_list_reverse (bitset, bitset_bindex *,
bitset_bindex, bitset_bindex *);
static void vbitset_set PARAMS ((bitset, bitset_bindex));
static void vbitset_reset PARAMS ((bitset, bitset_bindex));
static bool vbitset_test PARAMS ((bitset, bitset_bindex));
static bitset_bindex vbitset_list PARAMS ((bitset, bitset_bindex *,
bitset_bindex,
bitset_bindex *));
static bitset_bindex vbitset_list_reverse PARAMS ((bitset, bitset_bindex *,
bitset_bindex,
bitset_bindex *));
#define VBITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
#define VBITSET_WORDS(X) ((X)->b.cdata)
#define VBITSET_SIZE(X) ((X)->b.csize)
#define VBITSET_ASIZE(X) ((X)->v.size)
#undef min
#undef max
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
static bitset_bindex
vbitset_resize (bitset src, bitset_bindex n_bits)
vbitset_resize (src, n_bits)
bitset src;
bitset_bindex n_bits;
{
bitset_windex oldsize;
bitset_windex newsize;
@@ -337,7 +343,8 @@ vbitset_unused_clear (dst)
static void
vbitset_ones (bitset dst)
vbitset_ones (dst)
bitset dst;
{
bitset_word *dstp = VBITSET_WORDS (dst);
unsigned int bytes;
@@ -350,7 +357,8 @@ vbitset_ones (bitset dst)
static void
vbitset_zero (bitset dst)
vbitset_zero (dst)
bitset dst;
{
bitset_word *dstp = VBITSET_WORDS (dst);
unsigned int bytes;
@@ -362,7 +370,8 @@ vbitset_zero (bitset dst)
static bool
vbitset_empty_p (bitset dst)
vbitset_empty_p (dst)
bitset dst;
{
unsigned int i;
bitset_word *dstp = VBITSET_WORDS (dst);
@@ -376,7 +385,9 @@ vbitset_empty_p (bitset dst)
static void
vbitset_copy1 (bitset dst, bitset src)
vbitset_copy1 (dst, src)
bitset dst;
bitset src;
{
bitset_word *srcp;
bitset_word *dstp;
@@ -401,7 +412,9 @@ vbitset_copy1 (bitset dst, bitset src)
static void
vbitset_not (bitset dst, bitset src)
vbitset_not (dst, src)
bitset dst;
bitset src;
{
unsigned int i;
bitset_word *srcp;
@@ -426,7 +439,9 @@ vbitset_not (bitset dst, bitset src)
static bool
vbitset_equal_p (bitset dst, bitset src)
vbitset_equal_p (dst, src)
bitset dst;
bitset src;
{
unsigned int i;
bitset_word *srcp = VBITSET_WORDS (src);
@@ -456,7 +471,9 @@ vbitset_equal_p (bitset dst, bitset src)
static bool
vbitset_subset_p (bitset dst, bitset src)
vbitset_subset_p (dst, src)
bitset dst;
bitset src;
{
unsigned int i;
bitset_word *srcp = VBITSET_WORDS (src);
@@ -480,7 +497,9 @@ vbitset_subset_p (bitset dst, bitset src)
static bool
vbitset_disjoint_p (bitset dst, bitset src)
vbitset_disjoint_p (dst, src)
bitset dst;
bitset src;
{
unsigned int i;
bitset_word *srcp = VBITSET_WORDS (src);
@@ -497,7 +516,10 @@ vbitset_disjoint_p (bitset dst, bitset src)
static void
vbitset_and (bitset dst, bitset src1, bitset src2)
vbitset_and (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
bitset_word *src1p;
@@ -524,7 +546,10 @@ vbitset_and (bitset dst, bitset src1, bitset src2)
static bool
vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
vbitset_and_cmp (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
int changed = 0;
@@ -577,7 +602,10 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
static void
vbitset_andn (bitset dst, bitset src1, bitset src2)
vbitset_andn (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
bitset_word *src1p;
@@ -617,7 +645,10 @@ vbitset_andn (bitset dst, bitset src1, bitset src2)
static bool
vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
vbitset_andn_cmp (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
int changed = 0;
@@ -682,7 +713,10 @@ vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
static void
vbitset_or (bitset dst, bitset src1, bitset src2)
vbitset_or (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
bitset_word *src1p;
@@ -718,7 +752,10 @@ vbitset_or (bitset dst, bitset src1, bitset src2)
static bool
vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
vbitset_or_cmp (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
int changed = 0;
@@ -773,7 +810,10 @@ vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
static void
vbitset_xor (bitset dst, bitset src1, bitset src2)
vbitset_xor (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
bitset_word *src1p;
@@ -809,7 +849,10 @@ vbitset_xor (bitset dst, bitset src1, bitset src2)
static bool
vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
vbitset_xor_cmp (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
int changed = 0;
@@ -867,7 +910,11 @@ vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
bitsets. */
static void
vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
vbitset_and_or (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
{
unsigned int i;
bitset_word *src1p;
@@ -897,7 +944,11 @@ vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
static bool
vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
vbitset_and_or_cmp (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
{
unsigned int i;
int changed = 0;
@@ -934,7 +985,11 @@ vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
static void
vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
vbitset_andn_or (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
{
unsigned int i;
bitset_word *src1p;
@@ -964,7 +1019,11 @@ vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
static bool
vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
vbitset_andn_or_cmp (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
{
unsigned int i;
int changed = 0;
@@ -1001,7 +1060,11 @@ vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
static void
vbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
vbitset_or_and (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
{
unsigned int i;
bitset_word *src1p;
@@ -1031,7 +1094,11 @@ vbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
static bool
vbitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
vbitset_or_and_cmp (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
{
unsigned int i;
int changed = 0;
@@ -1067,8 +1134,10 @@ vbitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
}
static void
vbitset_copy (bitset dst, bitset src)
void
vbitset_copy (dst, src)
bitset dst;
bitset src;
{
if (BITSET_COMPATIBLE_ (dst, src))
vbitset_copy1 (dst, src);
+14 -13
View File
@@ -1,27 +1,28 @@
/* Functions to support vbitsets.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
Copyright (C) 2002 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
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 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 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, see <http://www.gnu.org/licenses/>. */
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _VBITSET_H
#define _VBITSET_H
#include "bitset.h"
extern size_t vbitset_bytes (bitset_bindex);
extern size_t vbitset_bytes PARAMS ((bitset_bindex));
extern bitset vbitset_init (bitset, bitset_bindex);
extern bitset vbitset_init PARAMS ((bitset, bitset_bindex));
#endif