diff options
author | Dan Willemsen <dwillemsen@google.com> | 2019-12-26 10:55:49 -0800 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2020-01-10 15:48:44 -0800 |
commit | 7eb5ee0e850619c037034d2725cb34d49f5c8302 (patch) | |
tree | fb72cbb0727a7285744a064861f9b9354f438a26 /lib/bitset.h | |
parent | a8ab20ff88a9b962a8eb39cdb6944a2354f78748 (diff) | |
download | bison-7eb5ee0e850619c037034d2725cb34d49f5c8302.tar.gz |
Replace with bison-3.5
This removes the previous contents, unpacks the bison-3.5 contents, then
adds the required android external files:
METADATA
MODULE_LICENSE_GPL
NOTICE
The Android.bp will be re-added in the next change.
Test: N/A -- see next change
Change-Id: Ibfbb6f583080f03fea83be58efdbbdbdca36c6f9
Diffstat (limited to 'lib/bitset.h')
-rw-r--r-- | lib/bitset.h | 142 |
1 files changed, 69 insertions, 73 deletions
diff --git a/lib/bitset.h b/lib/bitset.h index fbc7b778..ea04916e 100644 --- a/lib/bitset.h +++ b/lib/bitset.h @@ -1,6 +1,6 @@ /* Generic bitsets. - Copyright (C) 2002-2004, 2009-2012 Free Software Foundation, Inc. + Copyright (C) 2002-2004, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -15,31 +15,31 @@ 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, see <https://www.gnu.org/licenses/>. */ -#ifndef _BITSET_H -#define _BITSET_H +#ifndef _GL_BITSET_H +#define _GL_BITSET_H /* This file is the public interface to the bitset abstract data type. 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" #endif +#include "bitset/base.h" +#include "obstack.h" + /* 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; +typedef unsigned bitset_attrs; /* The contents of the union should be considered to be private. While I would like to make this union opaque, it needs to be @@ -49,26 +49,26 @@ union bitset_union { /* 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 tbitset_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 tbitset_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 @@ -80,9 +80,8 @@ union bitset_union struct vbitset_struct { struct bbitset_struct b; - bitset_windex size; /* Allocated size of array. */ + bitset_windex size; /* Allocated size of array. */ } v; - }; @@ -98,37 +97,37 @@ typedef struct /* Return bytes required for bitset of desired type and size. */ -extern size_t bitset_bytes (enum bitset_type, bitset_bindex); +size_t bitset_bytes (enum bitset_type, bitset_bindex); /* Initialise a bitset with desired type and size. */ -extern bitset bitset_init (bitset, bitset_bindex, enum bitset_type); +bitset bitset_init (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); +enum bitset_type bitset_type_choose (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); +bitset bitset_alloc (bitset_bindex, enum bitset_type); -/* Free bitset. */ -extern void bitset_free (bitset); +/* Free bitset. Do nothing if NULL. */ +void bitset_free (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); +bitset bitset_obstack_alloc (struct obstack *bobstack, + bitset_bindex, enum bitset_type); -/* Free bitset allocated on obstack. */ -extern void bitset_obstack_free (bitset); +/* Free bitset allocated on obstack. Do nothing if NULL. */ +void bitset_obstack_free (bitset); /* Create a bitset of desired size and attributes. The bitset is zeroed. */ -extern bitset bitset_create (bitset_bindex, bitset_attrs); +bitset bitset_create (bitset_bindex, bitset_attrs); /* Return bitset type. */ -extern enum bitset_type bitset_type_get (bitset); +enum bitset_type bitset_type_get (bitset); /* Return bitset type name. */ -extern const char *bitset_type_name_get (bitset); +const char *bitset_type_name_get (bitset); /* Set bit BITNO in bitset BSET. */ @@ -179,8 +178,9 @@ bitset_test (bitset bset, bitset_bindex bitno) /* Return size in bits of bitset SRC. */ #define bitset_size(SRC) BITSET_SIZE_ (SRC) -/* Change size of bitset. */ -extern void bitset_resize (bitset, bitset_bindex); +/* Change size in bits of bitset. New bits are zeroed. Return + SIZE. */ +#define bitset_resize(DST, SIZE) BITSET_RESIZE_ (DST, SIZE) /* Return number of bits set in bitset SRC. */ #define bitset_count(SRC) BITSET_COUNT_ (SRC) @@ -280,25 +280,25 @@ 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); +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); +bitset_bindex bitset_next (bitset, bitset_bindex); /* Find previous set bit from the given bit index. */ -extern bitset_bindex bitset_prev (bitset, bitset_bindex); +bitset_bindex bitset_prev (bitset, bitset_bindex); /* Find first set bit. */ -extern bitset_bindex bitset_first (bitset); +bitset_bindex bitset_first (bitset); /* Find last set bit. */ -extern bitset_bindex bitset_last (bitset); +bitset_bindex bitset_last (bitset); /* Return nonzero if this is the only set bit. */ -extern bool bitset_only_set_p (bitset, bitset_bindex); +bool bitset_only_set_p (bitset, bitset_bindex); /* Dump bitset. */ -extern void bitset_dump (FILE *, bitset); +void bitset_dump (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 @@ -308,18 +308,16 @@ extern void bitset_dump (FILE *, bitset); bitset_iterator iter; BITSET_FOR_EACH (iter, src, i, 0) - { - printf ("%lu ", (unsigned long int) i); - }; + printf ("%lu ", (unsigned long) 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 @@ -330,18 +328,16 @@ extern void bitset_dump (FILE *, bitset); bitset_iterator iter; BITSET_FOR_EACH_REVERSE (iter, src, i, 0) - { - printf ("%lu ", (unsigned long int) i); - }; + printf ("%lu ", (unsigned long) 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. */ @@ -367,13 +363,13 @@ extern void bitset_dump (FILE *, bitset); /* Release any memory tied up with bitsets. */ -extern void bitset_release_memory (void); +void bitset_release_memory (void); /* Enable bitset stats gathering. */ -extern void bitset_stats_enable (void); +void bitset_stats_enable (void); /* Disable bitset stats gathering. */ -extern void bitset_stats_disable (void); +void bitset_stats_disable (void); /* Read bitset stats file of accummulated stats. */ void bitset_stats_read (const char *file_name); @@ -382,12 +378,12 @@ void bitset_stats_read (const char *file_name); void bitset_stats_write (const char *file_name); /* Dump bitset stats. */ -extern void bitset_stats_dump (FILE *); +void bitset_stats_dump (FILE *); /* Function to debug bitset from debugger. */ -extern void debug_bitset (bitset); +void debug_bitset (bitset); /* Function to debug bitset stats from debugger. */ -extern void debug_bitset_stats (void); +void debug_bitset_stats (void); -#endif /* _BITSET_H */ +#endif /* _GL_BITSET_H */ |