X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/0fb669f9d648dfdd7a39478a6b658511455ae966..f2e1d4090df5b14fb7fdf33407df4f2bc7c5b342:/lib/bbitset.h diff --git a/lib/bbitset.h b/lib/bbitset.h index 3bcb92cd..443d2da2 100644 --- a/lib/bbitset.h +++ b/lib/bbitset.h @@ -1,20 +1,22 @@ /* Base bitset stuff. - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + + Copyright (C) 2002-2004, 2006, 2009-2013 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 . */ #ifndef _BBITSET_H #define _BBITSET_H @@ -30,17 +32,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Memory for bit array and bitset structure allocated contiguously. BITSET_LIST: Linked list of arrays of bits (variable size, least storage - for large very sparse sets). + for large very sparse sets). BITSET_TABLE: Expandable table of pointers to arrays of bits - (variable size, less storage for large sparse sets). + (variable size, less storage for large sparse sets). Faster than BITSET_LIST for random access. - BITSET_VARRAY: Variable array of bits (variable size, fast for + BITSET_VARRAY: Variable array of bits (variable size, fast for dense bitsets). BITSET_STATS: Wrapper bitset for internal use only. Used for gathering statistics and/or better run-time checking. */ enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_VARRAY, - BITSET_TYPE_NUM, BITSET_STATS}; + BITSET_TYPE_NUM, BITSET_STATS}; #define BITSET_TYPE_NAMES {"abitset", "lbitset", "ebitset", "vbitset"} extern const char * const bitset_type_names[]; @@ -76,19 +78,19 @@ typedef size_t bitset_windex; #define BITSET_LIST_SIZE 1024 enum bitset_ops {BITSET_OP_ZERO, BITSET_OP_ONES, - BITSET_OP_COPY, BITSET_OP_NOT, - BITSET_OP_EMPTY_P, BITSET_OP_EQUAL_P, - BITSET_OP_SUBSET_P, BITSET_OP_DISJOINT_P, - BITSET_OP_AND, BITSET_OP_OR, BITSET_OP_XOR, BITSET_OP_ANDN, - BITSET_OP_OR_AND, BITSET_OP_AND_OR, BITSET_OP_ANDN_OR}; + BITSET_OP_COPY, BITSET_OP_NOT, + BITSET_OP_EMPTY_P, BITSET_OP_EQUAL_P, + BITSET_OP_SUBSET_P, BITSET_OP_DISJOINT_P, + BITSET_OP_AND, BITSET_OP_OR, BITSET_OP_XOR, BITSET_OP_ANDN, + BITSET_OP_OR_AND, BITSET_OP_AND_OR, BITSET_OP_ANDN_OR}; struct bbitset_struct { const struct bitset_vtable *vtable; - bitset_windex cindex; /* Cache word index. */ - bitset_windex csize; /* Cache size in words. */ - bitset_word *cdata; /* Cache data pointer. */ - bitset_bindex n_bits; /* Number of bits. */ + bitset_windex cindex; /* Cache word index. */ + bitset_windex csize; /* Cache size in words. */ + bitset_word *cdata; /* Cache data pointer. */ + bitset_bindex n_bits; /* Number of bits. */ /* Perhaps we could sacrifice another word to indicate that the bitset is known to be zero, that a bit has been set in the cache, and that a bit has been cleared in the cache. @@ -126,16 +128,16 @@ struct bitset_vtable void (*copy) (bitset, bitset); bool (*disjoint_p) (bitset, bitset); bool (*equal_p) (bitset, bitset); - void (*not) (bitset, bitset); + void (*not_) (bitset, bitset); bool (*subset_p) (bitset, bitset); - void (*and) (bitset, 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); + void (*or_) (bitset, bitset, bitset); bool (*or_cmp) (bitset, bitset, bitset); - void (*xor) (bitset, bitset, bitset); + void (*xor_) (bitset, bitset, bitset); bool (*xor_cmp) (bitset, bitset, bitset); void (*and_or) (bitset, bitset, bitset, bitset); @@ -146,9 +148,9 @@ struct bitset_vtable bool (*or_and_cmp) (bitset, bitset, bitset, bitset); bitset_bindex (*list) (bitset, bitset_bindex *, bitset_bindex, - bitset_bindex *); + bitset_bindex *); bitset_bindex (*list_reverse) (bitset, bitset_bindex *, bitset_bindex, - bitset_bindex *); + bitset_bindex *); void (*free) (bitset); enum bitset_type type; }; @@ -218,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. */ @@ -233,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)