This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PCH] Use gengtype for some language stuff



Now working on the language subdirectories...

Tested on i686-pc-linux-gnu (bootstrap not necessary as the C frontend
was not touched).

-- 
Geoff Keating <geoffk@redhat.com>

===File ~/patches/pchbranch-moregc3.patch===================
Index: ChangeLog
2002-03-12  Geoffrey Keating  <geoffk@redhat.com>

	* Makefile.in (GTFILES): Add @all_gtfiles@.
	* configure: Regenerate.
	* configure.in: Construct all_gtfiles from the gtfiles definitions
	in config-lang.in.
	* gengtype-yacc.y (type): Warn about duplicate structure names.
	* gengtype.c (get_output_file): Handle .c files in language
	subdirectories.

Index: cp/ChangeLog
2002-03-12  Geoffrey Keating  <geoffk@redhat.com>

	* Make-lang.in (cp/gt-decl.h): Generate using gengtype.
	(cp/decl.o): Add cp/gt-decl.h dependency.
	* config-lang.in (gtfiles): New.
	* tree.h: Rename struct binding_level to struct cp_binding_level.
	* decl.c: Rename struct binding_level to struct cp_binding_level.
	Include cp/gt-decl.h.
	(struct cp_binding_level): Use gengtype.
	(make_binding_level): Use GGC on struct cp_binding_level.
	(mark_binding_level): Use gt_ggc_m_cp_binding_level.
	(cxx_init_decl_processing): Mark free_binding_level as
	deletable.

Index: f/ChangeLog
2002-03-12  Geoffrey Keating  <geoffk@redhat.com>

	* Make-lang.in (f/gt-com.h): Build using gengtype.
	(com.o): Depend on f/gt-com.h.
	* com.c: Rename struct binding_level to f_binding_level.
	(struct f_binding_level): Use gengtype.
	(struct tree_ggc_tracker): Use gengtype.
	(mark_tracker_head): Use gt_ggc_m_tree_ggc_tracker.
	(make_binding_level): Use GGC.
	(mark_binding_level): Use gt_ggc_m_f_binding_level.
	(ffecom_init_decl_processing): Change free_binding_level
	to a deletable root.
	* config-lang.in (gtfiles): Define.
	* where.c: Strings need no longer be allocated in GCable memory;
	remove my change of 30 Dec 1999.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.822.2.6
diff -p -u -p -r1.822.2.6 Makefile.in
--- Makefile.in	2002/03/12 18:53:11	1.822.2.6
+++ Makefile.in	2002/03/13 04:52:32
@@ -1775,8 +1775,9 @@ GTFILES = $(GCONFIG_H) \
   $(srcdir)/function.h  $(srcdir)/rtl.h $(srcdir)/optabs.h \
   $(srcdir)/except.c $(srcdir)/function.c $(srcdir)/integrate.c \
   $(srcdir)/stmt.c $(srcdir)/tree.c $(srcdir)/varasm.c \
+  $(out_file) \
   $(srcdir)/c-decl.c $(srcdir)/c-pragma.c \
-  $(out_file)
+  @all_gtfiles@
 
 gtype-desc.h gtype-desc.c gtype-c.h gt-except.h gt-function.h : s-gtype; @true
 gt-integrate.h gt-stmt.h gt-tree.h gt-varasm.h : s-gtype; @true
Index: configure
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure,v
retrieving revision 1.586.2.2
diff -p -u -p -r1.586.2.2 configure
--- configure	2002/03/09 10:56:07	1.586.2.2
+++ configure	2002/03/13 04:52:33
@@ -7917,6 +7917,8 @@ all_stagestuff=
 all_outputs='Makefile intl/Makefile fixinc/Makefile gccbug mklibgcc'
 # List of language makefile fragments.
 all_lang_makefiles=
+# Files for gengtype
+all_gtfiles=
 
 # Add the language fragments.
 # Languages are added via two mechanisms.  Some information must be
@@ -7937,6 +7939,7 @@ do
 		compilers=
 		stagestuff=
 		outputs=
+		gtfiles=
 		. ${srcdir}/$s/config-lang.in
 		if test "x$language" = x
 		then
@@ -7955,6 +7958,7 @@ do
 		all_compilers="$all_compilers $compilers"
 		all_stagestuff="$all_stagestuff $stagestuff"
 		all_outputs="$all_outputs $outputs"
+		all_gtfiles="$all_gtfiles $gtfiles"
 	fi
 done
 
@@ -8151,6 +8155,7 @@ ${CONFIG_SHELL-/bin/sh} $srcdir/configur
 
 
 
+
 # Echo that links are built
 if test x$host = x$target
 then
@@ -8413,6 +8418,7 @@ s%@objdir@%$objdir%g
 s%@subdirs@%$subdirs%g
 s%@all_boot_languages@%$all_boot_languages%g
 s%@all_compilers@%$all_compilers%g
+s%@all_gtfiles@%$all_gtfiles%g
 s%@all_lang_makefiles@%$all_lang_makefiles%g
 s%@all_languages@%$all_languages%g
 s%@all_stagestuff@%$all_stagestuff%g
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure.in,v
retrieving revision 1.576.2.1
diff -p -u -p -r1.576.2.1 configure.in
--- configure.in	2002/03/09 10:56:12	1.576.2.1
+++ configure.in	2002/03/13 04:52:33
@@ -2169,6 +2169,8 @@ all_stagestuff=
 all_outputs='Makefile intl/Makefile fixinc/Makefile gccbug mklibgcc'
 # List of language makefile fragments.
 all_lang_makefiles=
+# Files for gengtype
+all_gtfiles=
 
 # Add the language fragments.
 # Languages are added via two mechanisms.  Some information must be
@@ -2189,6 +2191,7 @@ do
 		compilers=
 		stagestuff=
 		outputs=
+		gtfiles=
 		. ${srcdir}/$s/config-lang.in
 		if test "x$language" = x
 		then
@@ -2207,6 +2210,7 @@ do
 		all_compilers="$all_compilers $compilers"
 		all_stagestuff="$all_stagestuff $stagestuff"
 		all_outputs="$all_outputs $outputs"
+		all_gtfiles="$all_gtfiles $gtfiles"
 	fi
 done
 
@@ -2339,6 +2343,7 @@ ${CONFIG_SHELL-/bin/sh} $srcdir/configur
 AC_SUBST(subdirs)
 AC_SUBST(all_boot_languages)
 AC_SUBST(all_compilers)
+AC_SUBST(all_gtfiles)
 AC_SUBST(all_lang_makefiles)
 AC_SUBST(all_languages)
 AC_SUBST(all_stagestuff)
Index: gengtype-yacc.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gengtype-yacc.y,v
retrieving revision 1.1.2.1
diff -p -u -p -r1.1.2.1 gengtype-yacc.y
--- gengtype-yacc.y	2002/03/09 10:56:18	1.1.2.1
+++ gengtype-yacc.y	2002/03/13 04:52:33
@@ -136,6 +136,11 @@ type: SCALAR
          {
 	   type_p t = find_structure ($2, 0);
 	   t->u.s.fields = $4;
+	   if (t->u.s.line.file)
+	     {
+	       error_at_line (&lexer_line, "duplicate structure definition");
+	       error_at_line (&t->u.s.line, "previous definition here");
+	     }
 	   t->u.s.line = lexer_line;
 	   $$ = t;
 	 }
@@ -145,6 +150,11 @@ type: SCALAR
          {
 	   type_p t = find_structure ($2, 1);
 	   t->u.s.fields = $4;
+	   if (t->u.s.line.file)
+	     {
+	       error_at_line (&lexer_line, "duplicate structure definition");
+	       error_at_line (&t->u.s.line, "previous definition here");
+	     }
 	   t->u.s.line = lexer_line;
 	   $$ = t;
 	 }
Index: gengtype.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gengtype.c,v
retrieving revision 1.1.2.3
diff -p -u -p -r1.1.2.3 gengtype.c
--- gengtype.c	2002/03/12 18:53:16	1.1.2.3
+++ gengtype.c	2002/03/13 04:52:33
@@ -255,7 +255,7 @@ get_output_file (input_file)
 {
   filemap_p fm, fmo;
   size_t len;
-  const char *basename;
+  const char *basename, *langname;
 
   /* Do we already know the file?  */
   for (fm = files; fm; fm = fm->next)
@@ -275,6 +275,15 @@ get_output_file (input_file)
     basename = input_file;
   else
     basename++;
+  langname = basename;
+  if (basename - input_file >= 2 && memcmp (basename-2, "f/", 2) == 0)
+    basename -= 2;
+  else if (basename - input_file >= 3 && memcmp (basename-3, "cp/", 3) == 0)
+    basename -= 3;
+  else if (basename - input_file >= 4 && memcmp (basename-4, "ada/", 4) == 0)
+    basename -= 4;
+  else if (basename - input_file >= 5 && memcmp (basename-5, "java/", 5) == 0)
+    basename -= 5;
 
   if (len > 2 && input_file[len-1] == 'c' && input_file[len-2] == '.')
     {
@@ -284,9 +293,11 @@ get_output_file (input_file)
       for (l = len-3; l >= 0; l--)
 	if (! isalnum (input_file[l]) && input_file[l] != '-')
 	  break;
-      fm->output_name = s = xmalloc (sizeof ("gt-") + len - l);
-      sprintf (s, "gt-%.*s.h", len - l - 3,
-	       input_file + l + 1);
+      fm->output_name = s = xmalloc (sizeof ("gt-") + len - l 
+				     + (langname - basename));
+      sprintf (s, "%.*sgt-%.*s.h", 
+	       langname - basename, basename,
+	       len - l - 3, input_file + l + 1);
       fm->output = create_file (input_file);
       return fm->output;
     }
Index: cp/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/Make-lang.in,v
retrieving revision 1.103.6.1
diff -p -u -p -r1.103.6.1 Make-lang.in
--- Make-lang.in	2002/02/13 23:36:27	1.103.6.1
+++ Make-lang.in	2002/03/13 04:52:46
@@ -143,6 +143,8 @@ c++.info: 
 c++.dvi:
 c++.generated-manpages:
 
+cp/gt-decl.h : s-gtype; @true
+
 #
 # Install hooks:
 # cc1plus is installed elsewhere as part of $(COMPILERS).
@@ -255,7 +257,7 @@ cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H)
   c-common.h
 cp/decl.o: cp/decl.c $(CXX_TREE_H) flags.h cp/lex.h cp/decl.h stack.h \
   output.h $(EXPR_H) except.h toplev.h hash.h $(GGC_H) $(RTL_H) \
-  cp/operators.def $(TM_P_H) tree-inline.h diagnostic.h
+  cp/operators.def $(TM_P_H) tree-inline.h diagnostic.h cp/gt-decl.h
 cp/decl2.o: cp/decl2.c $(CXX_TREE_H) flags.h cp/lex.h cp/decl.h $(EXPR_H) \
   output.h except.h toplev.h $(GGC_H) $(RTL_H)
 cp/typeck2.o: cp/typeck2.c $(CXX_TREE_H) flags.h toplev.h output.h $(TM_P_H) \
Index: cp/config-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/config-lang.in,v
retrieving revision 1.10
diff -p -u -p -r1.10 config-lang.in
--- config-lang.in	2001/12/20 00:20:45	1.10
+++ config-lang.in	2002/03/13 04:52:46
@@ -33,3 +33,5 @@ compilers="cc1plus\$(exeext)"
 stagestuff="g++\$(exeext) g++-cross\$(exeext) cc1plus\$(exeext)"
 
 target_libs="${libstdcxx_version} target-gperf"
+
+gtfiles="\$(srcdir)/cp/decl.c"
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.671.2.1
diff -p -u -p -r1.671.2.1 cp-tree.h
--- cp-tree.h	2002/02/13 23:36:28	1.671.2.1
+++ cp-tree.h	2002/03/13 04:52:46
@@ -348,7 +348,7 @@ struct tree_binding
   struct tree_common common;
   union {
     tree scope;
-    struct binding_level *level;
+    struct cp_binding_level *level;
   } scope;
   tree value;
 };
@@ -737,8 +737,8 @@ struct saved_scope
 
   struct stmt_tree_s x_stmt_tree;
 
-  struct binding_level *class_bindings;
-  struct binding_level *bindings;
+  struct cp_binding_level *class_bindings;
+  struct cp_binding_level *bindings;
 
   struct saved_scope *prev;
 };
@@ -827,7 +827,7 @@ struct cp_language_function
 
   struct named_label_use_list *x_named_label_uses;
   struct named_label_list *x_named_labels;
-  struct binding_level *bindings;
+  struct cp_binding_level *bindings;
   varray_type x_local_names;
 
   const char *cannot_inline;
@@ -1767,7 +1767,7 @@ struct lang_decl_flags
     tree template_info;
 
     /* In a NAMESPACE_DECL, this is NAMESPACE_LEVEL.  */
-    struct binding_level *level;
+    struct cp_binding_level *level;
   } u;
 
   union {
@@ -3653,13 +3653,13 @@ extern void finish_scope                
 extern void note_level_for_for			PARAMS ((void));
 extern void note_level_for_try			PARAMS ((void));
 extern void note_level_for_catch		PARAMS ((void));
-extern void resume_level			PARAMS ((struct binding_level *));
+extern void resume_level			PARAMS ((struct cp_binding_level *));
 extern void delete_block			PARAMS ((tree));
 extern void add_block_current_level		PARAMS ((tree));
 extern void pushlevel_class			PARAMS ((void));
 extern void poplevel_class                      PARAMS ((void));
 extern void print_binding_stack			PARAMS ((void));
-extern void print_binding_level			PARAMS ((struct binding_level *));
+extern void print_binding_level			PARAMS ((struct cp_binding_level *));
 extern void push_namespace			PARAMS ((tree));
 extern void pop_namespace			PARAMS ((void));
 extern void push_nested_namespace		PARAMS ((tree));
@@ -3747,7 +3747,7 @@ extern tree start_method			PARAMS ((tree
 extern tree finish_method			PARAMS ((tree));
 extern void hack_incomplete_structures		PARAMS ((tree));
 extern void finish_stmt				PARAMS ((void));
-extern void print_other_binding_stack		PARAMS ((struct binding_level *));
+extern void print_other_binding_stack		PARAMS ((struct cp_binding_level *));
 extern void revert_static_member_fn             PARAMS ((tree));
 extern void fixup_anonymous_aggr                PARAMS ((tree));
 extern int check_static_variable_definition     PARAMS ((tree, tree));
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.847.2.3
diff -p -u -p -r1.847.2.3 decl.c
--- decl.c	2002/03/12 18:53:44	1.847.2.3
+++ decl.c	2002/03/13 04:52:48
@@ -58,12 +58,12 @@ extern const struct attribute_spec *lang
 static tree grokparms				PARAMS ((tree));
 static const char *redeclaration_error_message	PARAMS ((tree, tree));
 
-static void push_binding_level PARAMS ((struct binding_level *, int,
+static void push_binding_level PARAMS ((struct cp_binding_level *, int,
 				      int));
 static void pop_binding_level PARAMS ((void));
 static void suspend_binding_level PARAMS ((void));
-static void resume_binding_level PARAMS ((struct binding_level *));
-static struct binding_level *make_binding_level PARAMS ((void));
+static void resume_binding_level PARAMS ((struct cp_binding_level *));
+static struct cp_binding_level *make_binding_level PARAMS ((void));
 static void declare_namespace_level PARAMS ((void));
 static int decl_jump_unsafe PARAMS ((tree));
 static void storedecls PARAMS ((tree));
@@ -82,19 +82,19 @@ static tree grokfndecl PARAMS ((tree, tr
 			      tree, int, int, int, int, int, int, tree));
 static tree grokvardecl PARAMS ((tree, tree, RID_BIT_TYPE *, int, int, tree));
 static tree lookup_tag PARAMS ((enum tree_code, tree,
-			      struct binding_level *, int));
+			      struct cp_binding_level *, int));
 static void set_identifier_type_value_with_scope
-	PARAMS ((tree, tree, struct binding_level *));
+	PARAMS ((tree, tree, struct cp_binding_level *));
 static void record_unknown_type PARAMS ((tree, const char *));
 static tree build_library_fn_1 PARAMS ((tree, enum tree_code, tree));
 static int member_function_or_else PARAMS ((tree, tree, enum overload_flags));
 static void bad_specifiers PARAMS ((tree, const char *, int, int, int, int,
 				  int));
-static tree maybe_process_template_type_declaration PARAMS ((tree, int, struct binding_level*));
+static tree maybe_process_template_type_declaration PARAMS ((tree, int, struct cp_binding_level*));
 static void check_for_uninitialized_const_var PARAMS ((tree));
 static unsigned long typename_hash PARAMS ((hash_table_key));
 static bool typename_compare PARAMS ((hash_table_key, hash_table_key));
-static void push_binding PARAMS ((tree, tree, struct binding_level*));
+static void push_binding PARAMS ((tree, tree, struct cp_binding_level*));
 static int add_binding PARAMS ((tree, tree));
 static void pop_binding PARAMS ((tree, tree));
 static tree local_variable_p_walkfn PARAMS ((tree *, int *, void *));
@@ -105,17 +105,17 @@ static tree qualify_lookup PARAMS ((tree
 static tree record_builtin_java_type PARAMS ((const char *, int));
 static const char *tag_name PARAMS ((enum tag_types code));
 static void find_class_binding_level PARAMS ((void));
-static struct binding_level *innermost_nonclass_level PARAMS ((void));
+static struct cp_binding_level *innermost_nonclass_level PARAMS ((void));
 static void warn_about_implicit_typename_lookup PARAMS ((tree, tree));
 static int walk_namespaces_r PARAMS ((tree, walk_namespaces_fn, void *));
 static int walk_globals_r PARAMS ((tree, void *));
-static void add_decl_to_level PARAMS ((tree, struct binding_level *));
+static void add_decl_to_level PARAMS ((tree, struct cp_binding_level *));
 static tree make_label_decl PARAMS ((tree, int));
 static void use_label PARAMS ((tree));
-static void check_previous_goto_1 PARAMS ((tree, struct binding_level *, tree,
+static void check_previous_goto_1 PARAMS ((tree, struct cp_binding_level *, tree,
 					   const char *, int));
 static void check_previous_goto PARAMS ((struct named_label_use_list *));
-static void check_switch_goto PARAMS ((struct binding_level *));
+static void check_switch_goto PARAMS ((struct cp_binding_level *));
 static void check_previous_gotos PARAMS ((tree));
 static void pop_label PARAMS ((tree, tree));
 static void pop_labels PARAMS ((tree));
@@ -219,7 +219,7 @@ static int only_namespace_names;
 
 struct named_label_use_list
 {
-  struct binding_level *binding_level;
+  struct cp_binding_level *binding_level;
   tree names_in_scope;
   tree label_decl;
   const char *filename_o_goto;
@@ -252,7 +252,7 @@ tree last_function_parms;
 
 struct named_label_list
 {
-  struct binding_level *binding_level;
+  struct cp_binding_level *binding_level;
   tree names_in_scope;
   tree old_value;
   tree label_decl;
@@ -343,7 +343,7 @@ int adding_implicit_members = 0;
 /* Note that the information in the `names' component of the global contour
    is duplicated in the IDENTIFIER_GLOBAL_VALUEs of all identifiers.  */
 
-struct binding_level
+struct cp_binding_level GTY(())
   {
     /* A chain of _DECL nodes for all variables, constants, functions,
        and typedef types.  These are in the reverse of the order
@@ -393,7 +393,7 @@ struct binding_level
     tree this_class;
 
     /* The binding level which this one is contained in (inherits from).  */
-    struct binding_level *level_chain;
+    struct cp_binding_level *level_chain;
 
     /* List of decls in `names' that have incomplete
        structure or union types.  */
@@ -448,13 +448,11 @@ struct binding_level
 
     /* Three bits left for this word.  */
 
-#if defined(DEBUG_CP_BINDING_LEVELS)
     /* Binding depth at which this level began.  */
     unsigned binding_depth;
-#endif /* defined(DEBUG_CP_BINDING_LEVELS) */
   };
 
-#define NULL_BINDING_LEVEL ((struct binding_level *) NULL)
+#define NULL_BINDING_LEVEL ((struct cp_binding_level *) NULL)
 
 /* The binding level currently in effect.  */
 
@@ -469,13 +467,13 @@ struct binding_level
 
 /* A chain of binding_level structures awaiting reuse.  */
 
-static struct binding_level *free_binding_level;
+static struct cp_binding_level *free_binding_level;
 
 /* The outermost binding level, for names of file scope.
    This is created when the compiler is started and exists
    through the entire run.  */
 
-static struct binding_level *global_binding_level;
+static struct cp_binding_level *global_binding_level;
 
 /* Nonzero means unconditionally make a BLOCK for the next level pushed.  */
 
@@ -495,16 +493,16 @@ indent ()
 }
 #endif /* defined(DEBUG_CP_BINDING_LEVELS) */
 
-static tree pushdecl_with_scope	PARAMS ((tree, struct binding_level *));
+static tree pushdecl_with_scope	PARAMS ((tree, struct cp_binding_level *));
 
 static void
 push_binding_level (newlevel, tag_transparent, keep)
-     struct binding_level *newlevel;
+     struct cp_binding_level *newlevel;
      int tag_transparent, keep;
 {
   /* Add this level to the front of the chain (stack) of levels that
      are active.  */
-  memset ((char*) newlevel, 0, sizeof (struct binding_level));
+  memset ((char*) newlevel, 0, sizeof (struct cp_binding_level));
   newlevel->level_chain = current_binding_level;
   current_binding_level = newlevel;
   newlevel->tag_transparent = tag_transparent;
@@ -527,7 +525,7 @@ push_binding_level (newlevel, tag_transp
 static void
 find_class_binding_level ()
 {
-  struct binding_level *level = current_binding_level;
+  struct cp_binding_level *level = current_binding_level;
 
   while (level && level->parm_flag != 2)
     level = level->level_chain;
@@ -561,7 +559,7 @@ pop_binding_level ()
   is_class_level = 0;
 #endif /* defined(DEBUG_CP_BINDING_LEVELS) */
   {
-    register struct binding_level *level = current_binding_level;
+    register struct cp_binding_level *level = current_binding_level;
     current_binding_level = current_binding_level->level_chain;
     level->level_chain = free_binding_level;
 #if 0 /* defined(DEBUG_CP_BINDING_LEVELS) */
@@ -605,7 +603,7 @@ suspend_binding_level ()
 
 static void
 resume_binding_level (b)
-     struct binding_level *b;
+     struct cp_binding_level *b;
 {
   /* Resuming binding levels is meant only for namespaces,
      and those cannot nest into classes. */
@@ -623,14 +621,14 @@ resume_binding_level (b)
 #endif /* defined(DEBUG_CP_BINDING_LEVELS) */
 }
 
-/* Create a new `struct binding_level'.  */
+/* Create a new `struct cp_binding_level'.  */
 
 static
-struct binding_level *
+struct cp_binding_level *
 make_binding_level ()
 {
   /* NOSTRICT */
-  return (struct binding_level *) xmalloc (sizeof (struct binding_level));
+  return (struct cp_binding_level *) ggc_alloc (sizeof (struct cp_binding_level));
 }
 
 /* Nonzero if we are currently in the global binding level.  */
@@ -643,10 +641,10 @@ global_bindings_p ()
 
 /* Return the innermost binding level that is not for a class scope.  */
 
-static struct binding_level *
+static struct cp_binding_level *
 innermost_nonclass_level ()
 {
-  struct binding_level *b;
+  struct cp_binding_level *b;
 
   b = current_binding_level;
   while (b->parm_flag == 2)
@@ -664,7 +662,7 @@ innermost_nonclass_level ()
 int
 toplevel_bindings_p ()
 {
-  struct binding_level *b = innermost_nonclass_level ();
+  struct cp_binding_level *b = innermost_nonclass_level ();
 
   return b->namespace_p || b->template_parms_p;
 }
@@ -676,7 +674,7 @@ toplevel_bindings_p ()
 int
 namespace_bindings_p ()
 {
-  struct binding_level *b = innermost_nonclass_level ();
+  struct cp_binding_level *b = innermost_nonclass_level ();
 
   return b->namespace_p;
 }
@@ -730,7 +728,7 @@ current_tmpl_spec_kind (n_class_scopes)
   int n_template_parm_scopes = 0;
   int seen_specialization_p = 0;
   int innermost_specialization_p = 0;
-  struct binding_level *b;
+  struct cp_binding_level *b;
 
   /* Scan through the template parameter scopes.  */
   for (b = current_binding_level; b->template_parms_p; b = b->level_chain)
@@ -823,7 +821,7 @@ void
 pushlevel (tag_transparent)
      int tag_transparent;
 {
-  struct binding_level *newlevel;
+  struct cp_binding_level *newlevel;
 
   if (cfun && !doing_semantic_analysis_p ())
     return;
@@ -918,7 +916,7 @@ note_level_for_catch ()
 }
 
 /* For a binding between a name and an entity at a block scope,
-   this is the `struct binding_level' for the block.  */
+   this is the `struct cp_binding_level' for the block.  */
 #define BINDING_LEVEL(NODE) \
   (((struct tree_binding*)(NODE))->scope.level)
 
@@ -934,7 +932,7 @@ static void
 push_binding (id, decl, level)
      tree id;
      tree decl;
-     struct binding_level* level;
+     struct cp_binding_level* level;
 {
   tree binding;
 
@@ -1037,7 +1035,7 @@ add_binding (id, decl)
 static void
 add_decl_to_level (decl, b)
      tree decl;
-     struct binding_level *b;
+     struct cp_binding_level *b;
 {
   /* We build up the list in reverse order, and reverse it later if
      necessary.  */
@@ -1056,7 +1054,7 @@ push_local_binding (id, decl, flags)
      tree decl;
      int flags;
 {
-  struct binding_level *b;
+  struct cp_binding_level *b;
 
   /* Skip over any local classes.  This makes sense if we call
      push_local_binding with a friend decl of a local class.  */
@@ -1307,7 +1305,7 @@ poplevel (keep, reverse, functionbody)
      under constraints of next binding contour.  */
   if (cfun && !functionbody)
     {
-      struct binding_level *level_chain;
+      struct cp_binding_level *level_chain;
       level_chain = current_binding_level->level_chain;
       if (level_chain)
 	{
@@ -1630,7 +1628,7 @@ set_block (block)
 void
 pushlevel_class ()
 {
-  register struct binding_level *newlevel;
+  register struct cp_binding_level *newlevel;
 
   /* Reuse or create a struct for this binding level.  */
 #if defined(DEBUG_CP_BINDING_LEVELS)
@@ -1661,7 +1659,7 @@ pushlevel_class ()
 void
 poplevel_class ()
 {
-  register struct binding_level *level = class_binding_level;
+  register struct cp_binding_level *level = class_binding_level;
   tree shadowed;
 
   my_friendly_assert (level != 0, 354);
@@ -1673,7 +1671,7 @@ poplevel_class ()
      next time we're entering a class scope, it is the same class.  */
   if (current_class_depth != 1)
     {
-      struct binding_level* b;
+      struct cp_binding_level* b;
 
       /* Clear out our IDENTIFIER_CLASS_VALUEs.  */
       for (shadowed = level->class_shadowed;
@@ -1935,28 +1933,13 @@ wrapup_globals_for_namespace (namespace,
 }
 
 
-/* Mark ARG (which is really a struct binding_level **) for GC.  */
+/* Mark ARG (which is really a struct cp_binding_level **) for GC.  */
 
 static void
 mark_binding_level (arg)
      void *arg;
 {
-  struct binding_level *lvl = *(struct binding_level **)arg;
-
-  for (; lvl; lvl = lvl->level_chain)
-    {
-      ggc_mark_tree (lvl->names);
-      ggc_mark_tree (lvl->tags);
-      ggc_mark_tree (lvl->usings);
-      ggc_mark_tree (lvl->using_directives);
-      ggc_mark_tree (lvl->class_shadowed);
-      ggc_mark_tree (lvl->type_shadowed);
-      ggc_mark_tree (lvl->shadowed_labels);
-      ggc_mark_tree (lvl->blocks);
-      ggc_mark_tree (lvl->this_class);
-      ggc_mark_tree (lvl->incomplete);
-      ggc_mark_tree (lvl->dead_vars_from_for);
-    }
+  gt_ggc_m_cp_binding_level (*(struct cp_binding_level **)arg);
 }
 
 static void
@@ -1986,7 +1969,7 @@ static int no_print_builtins = 0;
 
 void
 print_binding_level (lvl)
-     struct binding_level *lvl;
+     struct cp_binding_level *lvl;
 {
   tree t;
   int i = 0, len;
@@ -2089,9 +2072,9 @@ print_binding_level (lvl)
 
 void
 print_other_binding_stack (stack)
-     struct binding_level *stack;
+     struct cp_binding_level *stack;
 {
-  struct binding_level *level;
+  struct cp_binding_level *level;
   for (level = stack; level != global_binding_level; level = level->level_chain)
     {
       fprintf (stderr, "binding level ");
@@ -2104,7 +2087,7 @@ print_other_binding_stack (stack)
 void
 print_binding_stack ()
 {
-  struct binding_level *b;
+  struct cp_binding_level *b;
   fprintf (stderr, "current_binding_level=");
   fprintf (stderr, HOST_PTR_PRINTF, current_binding_level);
   fprintf (stderr, "\nclass_binding_level=");
@@ -2451,7 +2434,7 @@ maybe_push_to_top_level (pseudo)
      int pseudo;
 {
   struct saved_scope *s;
-  struct binding_level *b;
+  struct cp_binding_level *b;
   tree old_bindings;
   int need_pop;
 
@@ -2562,7 +2545,7 @@ static void
 set_identifier_type_value_with_scope (id, type, b)
      tree id;
      tree type;
-     struct binding_level *b;
+     struct cp_binding_level *b;
 {
   if (!b->namespace_p)
     {
@@ -2647,7 +2630,7 @@ static tree
 maybe_process_template_type_declaration (type, globalize, b)
      tree type;
      int globalize;
-     struct binding_level* b;
+     struct cp_binding_level* b;
 {
   tree decl = TYPE_NAME (type);
 
@@ -2768,7 +2751,7 @@ pushtag (name, type, globalize)
      tree name, type;
      int globalize;
 {
-  register struct binding_level *b;
+  register struct cp_binding_level *b;
 
   b = current_binding_level;
   while (b->tag_transparent
@@ -2899,7 +2882,7 @@ make_anon_name ()
 void
 clear_anon_tags ()
 {
-  register struct binding_level *b;
+  register struct cp_binding_level *b;
   register tree tags;
   static int last_cnt = 0;
 
@@ -4191,7 +4174,7 @@ pushdecl (x)
 		{
 		  /* Go to where the parms should be and see if we find
 		     them there.  */
-		  struct binding_level *b = current_binding_level->level_chain;
+		  struct cp_binding_level *b = current_binding_level->level_chain;
 
 		  /* ARM $8.3 */
 		  if (b->parm_flag == 1)
@@ -4264,9 +4247,9 @@ pushdecl (x)
 static tree
 pushdecl_with_scope (x, level)
      tree x;
-     struct binding_level *level;
+     struct cp_binding_level *level;
 {
-  register struct binding_level *b;
+  register struct cp_binding_level *b;
   tree function_decl = current_function_decl;
 
   current_function_decl = NULL_TREE;
@@ -4295,7 +4278,7 @@ tree
 pushdecl_namespace_level (x)
      tree x;
 {
-  register struct binding_level *b = current_binding_level;
+  register struct cp_binding_level *b = current_binding_level;
   register tree t;
 
   t = pushdecl_with_scope (x, NAMESPACE_LEVEL (current_namespace));
@@ -4938,14 +4921,14 @@ decl_jump_unsafe (decl)
 static void
 check_previous_goto_1 (decl, level, names, file, line)
      tree decl;
-     struct binding_level *level;
+     struct cp_binding_level *level;
      tree names;
      const char *file;
      int line;
 {
   int identified = 0;
   int saw_eh = 0;
-  struct binding_level *b = current_binding_level;
+  struct cp_binding_level *b = current_binding_level;
   for (; b; b = b->level_chain)
     {
       tree new_decls = b->names;
@@ -5012,7 +4995,7 @@ check_previous_goto (use)
 
 static void
 check_switch_goto (level)
-     struct binding_level *level;
+     struct cp_binding_level *level;
 {
   check_previous_goto_1 (NULL_TREE, level, level->names, NULL, 0);
 }
@@ -5114,7 +5097,7 @@ define_label (filename, line, name)
 {
   tree decl = lookup_label (name);
   struct named_label_list *ent;
-  register struct binding_level *p;
+  register struct cp_binding_level *p;
 
   for (ent = named_labels; ent; ent = ent->next)
     if (ent->label_decl == decl)
@@ -5152,7 +5135,7 @@ define_label (filename, line, name)
 
 struct cp_switch
 {
-  struct binding_level *level;
+  struct cp_binding_level *level;
   struct cp_switch *next;
   /* The SWITCH_STMT being built.  */
   tree switch_stmt;
@@ -5208,7 +5191,7 @@ finish_case_label (low_value, high_value
      tree high_value;
 {
   tree cond, r;
-  register struct binding_level *p;
+  register struct cp_binding_level *p;
 
   if (! switch_stack)
     {
@@ -5305,10 +5288,10 @@ static tree
 lookup_tag (form, name, binding_level, thislevel_only)
      enum tree_code form;
      tree name;
-     struct binding_level *binding_level;
+     struct cp_binding_level *binding_level;
      int thislevel_only;
 {
-  register struct binding_level *level;
+  register struct cp_binding_level *level;
   /* Non-zero if, we should look past a template parameter level, even
      if THISLEVEL_ONLY.  */
   int allow_template_parms_p = 1;
@@ -5421,7 +5404,7 @@ lookup_tag_reverse (type, name)
      tree type;
      tree name;
 {
-  register struct binding_level *level;
+  register struct cp_binding_level *level;
 
   for (level = current_binding_level; level; level = level->level_chain)
     {
@@ -5822,7 +5805,7 @@ unqualified_namespace_lookup (name, flag
   tree initial = current_decl_namespace ();
   tree scope = initial;
   tree siter;
-  struct binding_level *level;
+  struct cp_binding_level *level;
   tree val = NULL_TREE;
 
   if (spacesp)
@@ -6158,7 +6141,7 @@ tree
 lookup_name_current_level (name)
      tree name;
 {
-  struct binding_level *b;
+  struct cp_binding_level *b;
   tree t = NULL_TREE;
 
   b = current_binding_level;
@@ -6204,7 +6187,7 @@ lookup_type_current_level (name)
   if (REAL_IDENTIFIER_TYPE_VALUE (name) != NULL_TREE
       && REAL_IDENTIFIER_TYPE_VALUE (name) != global_type_node)
     {
-      struct binding_level *b = current_binding_level;
+      struct cp_binding_level *b = current_binding_level;
       while (1)
 	{
 	  if (purpose_member (name, b->type_shadowed))
@@ -6611,6 +6594,7 @@ cxx_init_decl_processing ()
   ggc_add_tree_root (&size_zero_node, 1);
   ggc_add_root (&global_binding_level, 1, sizeof global_binding_level,
 		mark_binding_level);
+  ggc_add_deletable_root (&free_binding_level, sizeof (free_binding_level));
   ggc_add_root (&scope_chain, 1, sizeof scope_chain, &mark_saved_scope);
   ggc_add_tree_root (&static_ctors, 1);
   ggc_add_tree_root (&static_dtors, 1);
@@ -7894,7 +7878,7 @@ maybe_inject_for_scope_var (decl)
 
   if (current_binding_level->is_for_scope)
     {
-      struct binding_level *outer
+      struct cp_binding_level *outer
 	= current_binding_level->level_chain;
 
       /* Check to see if the same name is already bound at the outer
@@ -9964,7 +9948,7 @@ grokdeclarator (declarator, declspecs, d
 
   if (decl_context == NORMAL && !toplevel_bindings_p ())
     {
-      struct binding_level *b = current_binding_level;
+      struct cp_binding_level *b = current_binding_level;
       current_binding_level = b->level_chain;
       if (current_binding_level != 0 && toplevel_bindings_p ())
 	decl_context = PARM;
@@ -12646,7 +12630,7 @@ xref_tag (code_type_node, name, globaliz
   enum tag_types tag_code;
   enum tree_code code;
   register tree ref, t;
-  struct binding_level *b = current_binding_level;
+  struct cp_binding_level *b = current_binding_level;
   int got_type = 0;
   tree attributes = NULL_TREE;
   tree context = NULL_TREE;
@@ -12842,14 +12826,14 @@ xref_tag (code_type_node, name, globaliz
 	}
       else
 	{
-	  struct binding_level *old_b = class_binding_level;
+	  struct cp_binding_level *old_b = class_binding_level;
 
 	  ref = make_aggr_type (code);
 	  TYPE_CONTEXT (ref) = context;
 
 #ifdef NONNESTED_CLASSES
 	  /* Class types don't nest the way enums do.  */
-	  class_binding_level = (struct binding_level *)0;
+	  class_binding_level = (struct cp_binding_level *)0;
 #endif
 	  pushtag (name, ref, globalize);
 	  class_binding_level = old_b;
@@ -13094,7 +13078,7 @@ start_enum (name)
      tree name;
 {
   register tree enumtype = NULL_TREE;
-  struct binding_level *b = current_binding_level;
+  struct cp_binding_level *b = current_binding_level;
 
   /* If this is the real definition for a previous forward reference,
      fill in the contents in the same object that used to be the
@@ -13444,7 +13428,7 @@ start_function (declspecs, declarator, a
   extern int have_extern_spec;
   extern int used_extern_spec;
   int doing_friend = 0;
-  struct binding_level *bl;
+  struct cp_binding_level *bl;
   tree current_function_parms;
 
   /* Sanity check.  */
@@ -14415,7 +14399,7 @@ hack_incomplete_structures (type)
      tree type;
 {
   tree *list;
-  struct binding_level *level;
+  struct cp_binding_level *level;
 
   if (!type) /* Don't do this for class templates.  */
     return;
@@ -14740,3 +14724,5 @@ cp_missing_noreturn_ok_p (decl)
   /* A missing noreturn is ok for the `main' function.  */
   return DECL_MAIN_P (decl);
 }
+
+#include "cp/gt-decl.h"
Index: f/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/Make-lang.in,v
retrieving revision 1.104.6.1
diff -p -u -p -r1.104.6.1 Make-lang.in
--- Make-lang.in	2002/02/13 23:36:36	1.104.6.1
+++ Make-lang.in	2002/03/13 04:52:48
@@ -137,6 +137,8 @@ f/fini.o:
 	$(HOST_CC) $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) \
 	      -c $(srcdir)/f/fini.c $(OUTPUT_OPTION)
 
+f/gt-com.h : s-gtype; @true
+
 #
 # Build hooks:
 
@@ -364,7 +366,7 @@ f/com.o: f/com.c f/proj.h $(CONFIG_H) $(
  f/bad.def f/where.h glimits.h f/top.h f/lex.h f/type.h f/intrin.h \
  f/intrin.def f/lab.h f/symbol.h f/symbol.def f/equiv.h f/storag.h f/global.h \
  f/name.h f/expr.h f/implic.h f/src.h f/st.h $(GGC_H) toplev.h diagnostic.h \
- langhooks.h langhooks-def.h intl.h
+ langhooks.h langhooks-def.h intl.h f/gt-com.h
 f/data.o: f/data.c f/proj.h $(CONFIG_H) $(SYSTEM_H) f/data.h f/bld.h f/bld-op.def \
  f/bit.h f/malloc.h f/com.h f/com-rt.def $(TREE_H) f/info.h f/info-b.def \
  f/info-k.def f/info-w.def f/target.h f/bad.h f/bad.def f/where.h glimits.h \
Index: f/com.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/com.c,v
retrieving revision 1.148.6.1
diff -p -u -p -r1.148.6.1 com.c
--- com.c	2002/02/13 23:36:36	1.148.6.1
+++ com.c	2002/03/13 04:52:50
@@ -366,7 +366,7 @@ static void finish_decl (tree decl, tree
 static void finish_function (int nested);
 static const char *lang_printable_name (tree decl, int v);
 static tree lookup_name_current_level (tree name);
-static struct binding_level *make_binding_level (void);
+static struct f_binding_level *make_binding_level (void);
 static void pop_f_function_context (void);
 static void push_f_function_context (void);
 static void push_parm_decl (tree parm);
@@ -521,7 +521,7 @@ static const char *const ffecom_gfrt_arg
 /* Note that the information in the `names' component of the global contour
    is duplicated in the IDENTIFIER_GLOBAL_VALUEs of all identifiers.  */
 
-struct binding_level
+struct f_binding_level GTY(())
   {
     /* A chain of _DECL nodes for all variables, constants, functions,
        and typedef types.  These are in the reverse of the order supplied.
@@ -538,7 +538,7 @@ struct binding_level
     tree this_block;
 
     /* The binding level which this one is contained in (inherits from).  */
-    struct binding_level *level_chain;
+    struct f_binding_level *level_chain;
 
     /* 0: no ffecom_prepare_* functions called at this level yet;
        1: ffecom_prepare* functions called, except not ffecom_prepare_end;
@@ -546,25 +546,25 @@ struct binding_level
     int prep_state;
   };
 
-#define NULL_BINDING_LEVEL (struct binding_level *) NULL
+#define NULL_BINDING_LEVEL (struct f_binding_level *) NULL
 
 /* The binding level currently in effect.  */
 
-static struct binding_level *current_binding_level;
+static struct f_binding_level *current_binding_level;
 
 /* A chain of binding_level structures awaiting reuse.  */
 
-static struct binding_level *free_binding_level;
+static struct f_binding_level *free_binding_level;
 
 /* The outermost binding level, for names of file scope.
    This is created when the compiler is started and exists
    through the entire run.  */
 
-static struct binding_level *global_binding_level;
+static struct f_binding_level *global_binding_level;
 
 /* Binding level structures are initialized by copying this one.  */
 
-static const struct binding_level clear_binding_level
+static const struct f_binding_level clear_binding_level
 =
 {NULL, NULL, NULL, NULL_BINDING_LEVEL, 0};
 
@@ -6262,26 +6262,17 @@ ffecom_gfrt_tree_ (ffecomGfrt ix)
 /* A somewhat evil way to prevent the garbage collector
    from collecting 'tree' structures.  */
 #define NUM_TRACKED_CHUNK 63
-static struct tree_ggc_tracker
+struct tree_ggc_tracker GTY(())
 {
   struct tree_ggc_tracker *next;
   tree trees[NUM_TRACKED_CHUNK];
-} *tracker_head = NULL;
+};
+static struct tree_ggc_tracker *tracker_head = NULL;
 
 static void
 mark_tracker_head (void *arg)
 {
-  struct tree_ggc_tracker *head;
-  int i;
-
-  for (head = * (struct tree_ggc_tracker **) arg;
-       head != NULL;
-       head = head->next)
-  {
-    ggc_mark (head);
-    for (i = 0; i < NUM_TRACKED_CHUNK; i++)
-      ggc_mark_tree (head->trees[i]);
-  }
+  gt_ggc_m_tree_ggc_tracker (* (struct tree_ggc_tracker **) arg);
 }
 
 void
@@ -13722,13 +13713,13 @@ lookup_name_current_level (tree name)
   return t;
 }
 
-/* Create a new `struct binding_level'.  */
+/* Create a new `struct f_binding_level'.  */
 
-static struct binding_level *
+static struct f_binding_level *
 make_binding_level ()
 {
   /* NOSTRICT */
-  return (struct binding_level *) xmalloc (sizeof (struct binding_level));
+  return ggc_alloc (sizeof (struct f_binding_level));
 }
 
 /* Save and restore the variables in this file and elsewhere
@@ -13740,7 +13731,7 @@ struct f_function
   struct f_function *next;
   tree named_labels;
   tree shadowed_labels;
-  struct binding_level *binding_level;
+  struct f_binding_level *binding_level;
 };
 
 struct f_function *f_function_chain;
@@ -13828,7 +13819,7 @@ pushdecl_top_level (x)
      tree x;
 {
   register tree t;
-  register struct binding_level *b = current_binding_level;
+  register struct f_binding_level *b = current_binding_level;
   register tree f = current_function_decl;
 
   current_binding_level = global_binding_level;
@@ -14096,15 +14087,7 @@ incomplete_type_error (value, type)
 static void
 mark_binding_level (void *arg)
 {
-  struct binding_level *level = *(struct binding_level **) arg;
-
-  while (level)
-    {
-      ggc_mark_tree (level->names);
-      ggc_mark_tree (level->blocks);
-      ggc_mark_tree (level->this_block);
-      level = level->level_chain;
-    }
+  gt_ggc_m_f_binding_level (*(struct f_binding_level **) arg);
 }
 
 static void
@@ -14168,8 +14151,7 @@ ffecom_init_decl_processing ()
   ggc_add_tree_root (ffecom_gfrt_, FFECOM_gfrt);
   ggc_add_root (&current_binding_level, 1, sizeof current_binding_level,
                 mark_binding_level);
-  ggc_add_root (&free_binding_level, 1, sizeof current_binding_level,
-                mark_binding_level);
+  ggc_add_deletable_root (&free_binding_level, sizeof free_binding_level);
   ggc_add_root (&tracker_head, 1, sizeof tracker_head, mark_tracker_head);
 
   ffe_init_0 ();
@@ -14489,7 +14471,7 @@ poplevel (keep, reverse, functionbody)
   /* Pop the current level, and free the structure for reuse.  */
 
   {
-    register struct binding_level *level = current_binding_level;
+    register struct f_binding_level *level = current_binding_level;
     current_binding_level = current_binding_level->level_chain;
 
     level->level_chain = free_binding_level;
@@ -14544,7 +14526,7 @@ pushdecl (x)
 {
   register tree t;
   register tree name = DECL_NAME (x);
-  register struct binding_level *b = current_binding_level;
+  register struct f_binding_level *b = current_binding_level;
 
   if ((TREE_CODE (x) == FUNCTION_DECL)
       && (DECL_INITIAL (x) == 0)
@@ -14676,7 +14658,7 @@ void
 pushlevel (tag_transparent)
      int tag_transparent;
 {
-  register struct binding_level *newlevel = NULL_BINDING_LEVEL;
+  register struct f_binding_level *newlevel = NULL_BINDING_LEVEL;
 
   assert (! tag_transparent);
 
@@ -16628,3 +16610,5 @@ typedef doublereal E_f; // real function
 -------- (end output file from f2c)
 
 */
+
+#include "f/gt-com.h"
Index: f/config-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/config-lang.in,v
retrieving revision 1.11
diff -p -u -p -r1.11 config-lang.in
--- config-lang.in	2001/12/20 00:20:46	1.11
+++ config-lang.in	2002/03/13 04:52:50
@@ -32,3 +32,5 @@ compilers="f771\$(exeext)"
 stagestuff="g77\$(exeext) g77-cross\$(exeext) f771\$(exeext)"
 
 target_libs=target-libf2c
+
+gtfiles="\$(srcdir)/f/com.c"
Index: f/where.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/where.c,v
retrieving revision 1.9
diff -p -u -p -r1.9 where.c
--- where.c	2000/06/21 20:11:14	1.9
+++ where.c	2002/03/13 04:52:50
@@ -33,7 +33,6 @@ the Free Software Foundation, 59 Temple 
 #include "where.h"
 #include "lex.h"
 #include "malloc.h"
-#include "ggc.h"
 
 /* Externals defined here. */
 
@@ -109,32 +108,6 @@ ffewhere_ll_lookup_ (ffewhereLineNumber 
   return NULL;
 }
 
-/* A somewhat evil way to prevent the garbage collector
-   from collecting 'file' structures.  */
-#define NUM_FFEWHERE_HEAD_FILES 31
-static struct ffewhere_ggc_tracker 
-{
-  struct ffewhere_ggc_tracker *next;
-  ffewhereFile files[NUM_FFEWHERE_HEAD_FILES];
-} *ffewhere_head = NULL;
-
-static void 
-mark_ffewhere_head (void *arg)
-{
-  struct ffewhere_ggc_tracker *head;
-  int i;
-  
-  for (head = * (struct ffewhere_ggc_tracker **) arg;
-       head != NULL;
-       head = head->next)
-  {
-    ggc_mark (head);
-    for (i = 0; i < NUM_FFEWHERE_HEAD_FILES; i++)
-      ggc_mark (head->files[i]);
-  }
-}
-
-
 /* Kill file object.
 
    Note that this object must not have been passed in a call
@@ -144,18 +117,9 @@ mark_ffewhere_head (void *arg)
 void
 ffewhere_file_kill (ffewhereFile wf)
 {
-  struct ffewhere_ggc_tracker *head;
-  int i;
-  
-  for (head = ffewhere_head; head != NULL; head = head->next)
-    for (i = 0; i < NUM_FFEWHERE_HEAD_FILES; i++)
-      if (head->files[i] == wf)
-	{
-	  head->files[i] = NULL;
-	  return;
-	}
-  /* Called on a file that has already been deallocated... */
-  abort();
+  malloc_kill_ks (ffe_pool_file (), wf,
+		  offsetof (struct _ffewhere_file_, text)
+		  + wf->length + 1);
 }
 
 /* Create file object.  */
@@ -164,41 +128,13 @@ ffewhereFile
 ffewhere_file_new (const char *name, size_t length)
 {
   ffewhereFile wf;
-  int filepos;
- 
-  wf = ggc_alloc (offsetof (struct _ffewhere_file_, text)
-		  + length + 1);
+
+  wf = malloc_new_ks (ffe_pool_file (), "ffewhereFile",
+		      offsetof (struct _ffewhere_file_, text)
+		      + length + 1);
   wf->length = length;
   memcpy (&wf->text[0], name, length);
   wf->text[length] = '\0';
-
-  if (ffewhere_head == NULL)
-    {
-      ggc_add_root (&ffewhere_head, 1, sizeof ffewhere_head,
-		    mark_ffewhere_head);
-      filepos = NUM_FFEWHERE_HEAD_FILES;
-    }
-  else
-    {
-      for (filepos = 0; filepos < NUM_FFEWHERE_HEAD_FILES; filepos++)
-	if (ffewhere_head->files[filepos] == NULL)
-	  {
-	    ffewhere_head->files[filepos] = wf;
-	    break;
-	  }
-    }
-  if (filepos == NUM_FFEWHERE_HEAD_FILES)
-    {
-      /* Need to allocate a new block.  */
-      struct ffewhere_ggc_tracker *old_head = ffewhere_head;
-      int i;
-      
-      ffewhere_head = ggc_alloc (sizeof (*ffewhere_head));
-      ffewhere_head->next = old_head;
-      ffewhere_head->files[0] = wf;
-      for (i = 1; i < NUM_FFEWHERE_HEAD_FILES; i++)
-	ffewhere_head->files[i] = NULL;
-    }
 
   return wf;
 }
============================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]