@@ -68,6 +68,7 @@ These don't need to be marked.
@menu
* GTY Options:: What goes inside a @code{GTY(())}.
* GGC Roots:: Making global variables GGC roots.
+* User GC:: Adding user-provided GC marking routines.
* Files:: How the generated files work.
* Invoking the garbage collector:: How to invoke the garbage collector.
* Troubleshooting:: When something does not work as expected.
@@ -435,20 +436,53 @@ The @code{special} option is used to mark types
that have to be dealt
with by special case machinery. The parameter is the name of the
special case. See @file{gengtype.c} for further details. Avoid
adding new special cases unless there is no other alternative.
+
+@findex user
+@item user
+
+The @code{user} option indicates that the code to mark structure
+fields is completely handled by user-provided routines. Section
+@ref{User GC} for details on what functions need to be provided.
@end table
+@node User GC
@section Support for user-provided GC marking routines
+@cindex user gc
The garbage collector supports types for which no automatic marking
code is generated. For these types, the user is required to provide
four functions: one to act as a marker for garbage collection, and
-three functions to act as marker and pointer walking for pre-compiled
+two functions to act as marker and pointer walking for pre-compiled
headers.
-User-provided types are currently supported for C++ template
-structures. When a template type @code{TP} is marked with @code{GTY},
-all instances of that type are considered user-provided types. As
-such, the user needs to provide template functions to mark all the
-fields of the type.
+Given a structure @code{struct GTY((user)) my_struct}, the following
functions
+should be defined to mark @code{my_struct}
+
+@smallexample
+void gt_ggc_mx (my_struct *p)
+@{
+ /* This marks field 'fld'. */
+ gt_ggc_mx (p->fld);
+@}
+
+void gt_pch_nx (my_struct *p)
+@{
+ /* This marks field 'fld'. */
+ gt_pch_nx (tp->fld);
+@}
+
+void gt_pch_nx (my_struct *p, gt_pointer_operator op, void *cookie)
+@{
+ /* For every field 'fld', call the given pointer operator. */
+ op (&(tp->fld), cookie);
+@}
+@end smallexample
+
+@section User-provided marking routines for template types
+When a template type @code{TP} is marked with @code{GTY}, all
+instances of that type are considered user-provided types. This means
+that the individual instances of @code{TP} do not need to marked with
+@code{GTY}. The user needs to provide template functions to mark all
+the fields of the type.