summaryrefslogtreecommitdiffstats
path: root/gcc/cpphash.c
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2000-07-05 05:33:57 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2000-07-05 05:33:57 +0000
commitf51c214891c0d16cba6159712002fa8733653a65 (patch)
tree0faabdcd2aa742b82e58d484b96722dd2b861e6e /gcc/cpphash.c
parentffbff7a4f5806675b9373a398e619ff5e6173117 (diff)
downloadppe42-gcc-f51c214891c0d16cba6159712002fa8733653a65.tar.gz
ppe42-gcc-f51c214891c0d16cba6159712002fa8733653a65.zip
toplevel:
* cpplex.c: Don't include sys/mman.h. (cpp_push_buffer, cpp_pop_buffer): Moved to cpplib.c. * cpplib.c: Include sys/mman.h and obstack.h. (cpp_push_buffer): Moved from cpplex.c; allocate buffers on an obstack. (cpp_pop_buffer): Moved from cpplex.c; free buffers from an obstack. (_cpp_unwind_if_stack): Now static, unwind_if_stack. Don't bother freeing if stack entries (they will be freed with their buffer). (do_endif): Free if stack entries from the buffer obstack. (push_conditional): Allocate if stack entries from the buffer obstack. (find_answer): Rename to _cpp_find_answer. (do_assert, do_unassert): Update. * cpphash.h: Update prototypes. (xobnew): New convenience macro. * cpplib.h (struct cpp_reader): Add hash_ob and buffer_ob fields. Update comments. (struct cpp_hashnode): Remove disabled field. * cppinit.c: Don't include hashtab.h or splay-tree.h. (report_missing_guard): Moved to cppfiles.c. (cpp_reader_init): Call cpp_init_stacks, cpp_init_macros, cpp_init_includes. (cpp_cleanup): Call cpp_cleanup_stacks, cpp_cleanup_macros, cpp_cleanup_includes. Don't destroy hashtab or all_include_files here. (cpp_finish): Use _cpp_report_missing_guards. * cppfiles.c (report_missing_guard): Moved from cppinit.c. (_cpp_init_include_table): Rename _cpp_init_includes. (_cpp_cleanup_includes, _cpp_report_missing_guards): New. * cppexp.c (parse_assertion): Update for new name of find_answer. * Makefile.in (cpplib.o, cpphash.o, cppinit.o): Update deps. * cpplib.c (do_ident): s/VSPACE/EOF/ testsuite: * gcc.dg/cpp/ident.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34870 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpphash.c')
-rw-r--r--gcc/cpphash.c75
1 files changed, 31 insertions, 44 deletions
diff --git a/gcc/cpphash.c b/gcc/cpphash.c
index ba812d5e2de..2007c52d661 100644
--- a/gcc/cpphash.c
+++ b/gcc/cpphash.c
@@ -26,10 +26,12 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "config.h"
#include "system.h"
#include "cpplib.h"
-#include "hashtab.h"
#include "cpphash.h"
+#include "hashtab.h"
+#include "obstack.h"
-#undef abort
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
/* This is the second argument to eq_HASHNODE. */
struct hashdummy
@@ -43,9 +45,6 @@ struct hashdummy
static unsigned int hash_HASHNODE PARAMS ((const void *));
static int eq_HASHNODE PARAMS ((const void *, const void *));
-static void del_HASHNODE PARAMS ((void *));
-static cpp_hashnode *make_HASHNODE PARAMS ((const U_CHAR *, size_t,
- enum node_type, unsigned int));
static int dump_hash_helper PARAMS ((void **, void *));
static void dump_funlike_macro PARAMS ((cpp_reader *, cpp_hashnode *));
@@ -105,41 +104,6 @@ eq_HASHNODE (x, y)
&& !ustrncmp (a->name, b->name, a->length));
}
-/* Destroy a cpp_hashnode. */
-static void
-del_HASHNODE (x)
- void *x;
-{
- cpp_hashnode *h = (cpp_hashnode *)x;
-
- _cpp_free_definition (h);
- free (h);
-}
-
-/* Allocate and initialize a cpp_hashnode structure.
- Caller must fill in the value field. */
-
-static cpp_hashnode *
-make_HASHNODE (name, len, type, hash)
- const U_CHAR *name;
- size_t len;
- enum node_type type;
- unsigned int hash;
-{
- cpp_hashnode *hp = (cpp_hashnode *) xmalloc (sizeof (cpp_hashnode) + len);
- U_CHAR *p = (U_CHAR *)hp + offsetof (cpp_hashnode, name);
-
- hp->type = type;
- hp->length = len;
- hp->hash = hash;
- hp->disabled = 0;
-
- memcpy (p, name, len);
- p[len] = 0;
-
- return hp;
-}
-
/* Find the hash node for name "name", of length LEN. */
cpp_hashnode *
@@ -151,6 +115,7 @@ cpp_lookup (pfile, name, len)
struct hashdummy dummy;
cpp_hashnode *new, **slot;
unsigned int hash;
+ U_CHAR *p;
dummy.name = name;
dummy.length = len;
@@ -161,20 +126,42 @@ cpp_lookup (pfile, name, len)
if (*slot)
return *slot;
- new = make_HASHNODE (name, len, T_VOID, hash);
+ /* Create a new hash node. */
+ p = obstack_alloc (pfile->hash_ob, sizeof (cpp_hashnode) + len);
+ new = (cpp_hashnode *)p;
+ p += offsetof (cpp_hashnode, name);
+
+ new->type = T_VOID;
+ new->length = len;
+ new->hash = hash;
+ new->fe_value = 0;
new->value.expansion = NULL;
+ memcpy (p, name, len);
+ p[len] = 0;
+
*slot = new;
return new;
}
-/* Init the hash table. In here so it can see the hash and eq functions. */
+/* Set up and tear down internal structures for macro expansion. */
void
-_cpp_init_macro_hash (pfile)
+_cpp_init_macros (pfile)
cpp_reader *pfile;
{
pfile->hashtab = htab_create (HASHSIZE, hash_HASHNODE,
- eq_HASHNODE, del_HASHNODE);
+ eq_HASHNODE, (htab_del) _cpp_free_definition);
+ pfile->hash_ob = xnew (struct obstack);
+ obstack_init (pfile->hash_ob);
+}
+
+void
+_cpp_cleanup_macros (pfile)
+ cpp_reader *pfile;
+{
+ htab_delete (pfile->hashtab);
+ obstack_free (pfile->hash_ob, 0);
+ free (pfile->hash_ob);
}
/* Free the definition of macro H. */
OpenPOWER on IntegriCloud