summaryrefslogtreecommitdiff
path: root/gcc/stringpool.c
diff options
context:
space:
mode:
authorgeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-09 20:10:13 +0000
committergeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-09 20:10:13 +0000
commitc39ed964c8cd9aec2fe6060830804416b0856b60 (patch)
tree1238be7fc80d74d8323d5f6c4344a6bb2be0f854 /gcc/stringpool.c
parentf5efe504032463d907b2eb0f4f76a5d68ce45429 (diff)
downloadgcc-c39ed964c8cd9aec2fe6060830804416b0856b60.tar.gz
Index: gcc/ChangeLog
2004-06-09 Geoffrey Keating <geoffk@apple.com> * Makefile.in (CPPLIB_H): Put files in order of inclusion. (CPP_ID_DATA_H): New. (gtype-desc.o): Update dependencies. (GTFILES): Use CPP_ID_DATA_H. Index: gcc/testsuite/ChangeLog 2004-06-09 Geoffrey Keating <geoffk@apple.com> * gcc.dg/pch/macro-4.c: New. * gcc.dg/pch/macro-4.hs: New. Index: libcpp/ChangeLog 2004-06-09 Geoffrey Keating <geoffk@apple.com> * traditional.c (push_replacement_text): Set macro->traditional. (save_replacement_text): Likewise. * pch.c (cpp_write_pch_state): Don't write list of defined macros. (struct save_macro_item): Delete. (struct save_macro_data): Use a character array not the previous structured format. (save_macros): Save macro as text not as internal structures. (cpp_prepare_state): Update for changes to save_macro_data. (cpp_read_state): Don't read macros defined in PCH. Restore -D macros as text. * macro.c (create_iso_definition): Honour alloc_subobject. Clear traditional flag. (_cpp_create_definition): Honour alloc_subobject. * lex.c (cpp_token_val_index): New. * internal.h: Include cpp-id-data.h. (uchar): Move definition to cpp-id-data.h. (U): Likewise. (cpp_macro): Likewise. * directives.c (struct answer): Move to cpp-id-data.h. (do_assert): Honour alloc_subobject. Index: libcpp/include/ChangeLog 2004-06-09 Geoffrey Keating <geoffk@apple.com> * symtab.h (struct ht): Add field 'alloc_subobject'. * cpplib.h (struct cpp_string): Add GTY marker. (enum cpp_token_fld_kind): New. (struct cpp_token): Add GTY markers. (cpp_token_val_index): Prototype. (CPP_HASHNODE_VALUE_IDX): New. (struct cpp_hashnode): Don't skip fields of 'value' when marking. * cpp-id-data.h: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@82851 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/stringpool.c')
-rw-r--r--gcc/stringpool.c49
1 files changed, 8 insertions, 41 deletions
diff --git a/gcc/stringpool.c b/gcc/stringpool.c
index d17f31decdd..0227688f6e1 100644
--- a/gcc/stringpool.c
+++ b/gcc/stringpool.c
@@ -51,7 +51,12 @@ static struct obstack string_stack;
static hashnode alloc_node (hash_table *);
static int mark_ident (struct cpp_reader *, hashnode, const void *);
-static int ht_copy_and_clear (struct cpp_reader *, hashnode, const void *);
+
+static void *
+stringpool_ggc_alloc (size_t x)
+{
+ return ggc_alloc (x);
+}
/* Initialize the string pool. */
void
@@ -60,6 +65,7 @@ init_stringpool (void)
/* Create with 16K (2^14) entries. */
ident_hash = ht_create (14);
ident_hash->alloc_node = alloc_node;
+ ident_hash->alloc_subobject = stringpool_ggc_alloc;
gcc_obstack_init (&string_stack);
}
@@ -212,39 +218,7 @@ struct string_pool_data GTY(())
static GTY(()) struct string_pool_data * spd;
-/* Copy HP into the corresponding entry in HT2, and then clear
- the cpplib parts of HP. */
-
-static int
-ht_copy_and_clear (cpp_reader *r ATTRIBUTE_UNUSED, hashnode hp, const void *ht2_p)
-{
- cpp_hashnode *h = CPP_HASHNODE (hp);
- struct ht *ht2 = (struct ht *) ht2_p;
-
- if (h->type != NT_VOID
- && (h->flags & NODE_BUILTIN) == 0)
- {
- cpp_hashnode *h2 = CPP_HASHNODE (ht_lookup (ht2,
- NODE_NAME (h),
- NODE_LEN (h),
- HT_ALLOC));
- h2->type = h->type;
- memcpy (&h2->value, &h->value, sizeof (h->value));
-
- h->type = NT_VOID;
- memset (&h->value, 0, sizeof (h->value));
- }
- return 1;
-}
-
-/* The hash table as it was before gt_pch_save_stringpool was called. */
-
-static struct ht *saved_ident_hash;
-
-/* Prepare the stringpool to be written (by clearing all the cpp parts
- of each entry) and place the data to be saved in SPD. Save the
- current state in SAVED_IDENT_HASH so that gt_pch_fixup_stringpool
- can restore it. */
+/* Save the stringpool data in SPD. */
void
gt_pch_save_stringpool (void)
@@ -255,10 +229,6 @@ gt_pch_save_stringpool (void)
spd->entries = ggc_alloc (sizeof (spd->entries[0]) * spd->nslots);
memcpy (spd->entries, ident_hash->entries,
spd->nslots * sizeof (spd->entries[0]));
-
- saved_ident_hash = ht_create (14);
- saved_ident_hash->alloc_node = alloc_node;
- ht_forall (ident_hash, ht_copy_and_clear, saved_ident_hash);
}
/* Return the stringpool to its state before gt_pch_save_stringpool
@@ -267,9 +237,6 @@ gt_pch_save_stringpool (void)
void
gt_pch_fixup_stringpool (void)
{
- ht_forall (saved_ident_hash, ht_copy_and_clear, ident_hash);
- ht_destroy (saved_ident_hash);
- saved_ident_hash = 0;
}
/* A PCH file has been restored, which loaded SPD; fill the real hash table