This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How to GTYize a struct properly?
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: Laurynas Biveinis <laurynas dot biveinis at gmail dot com>
- Cc: GCC Mailing List <gcc at gcc dot gnu dot org>
- Date: Sun, 13 Aug 2006 20:00:11 -0400
- Subject: Re: How to GTYize a struct properly?
- References: <d1e3ff2b0608131140y55a49601we31a4119fe1738df@mail.gmail.com>
Laurynas Biveinis wrote:
> Hi,
>
> For typed GC allocation I've to add GTY markers for a few datatypes.
> An example from value-prof.h:
>
> Before:
>
> struct histogram_value_t
> {
> struct
> { /* <--- line 48, error below occurs here */
> tree value; /* The value to profile. */
> tree stmt; /* Insn containing the value. */
> gcov_type *counters; /* Pointer to first counter. */
> struct histogram_value_t *next; /* Linked list pointer. */
> } hvalue;
> enum hist_type type; /* Type of information to measure. */
> unsigned n_counters; /* Number of required counters. */
> union
> {
> struct
> {
> int int_start; /* First value in interval. */
> unsigned int steps; /* Number of values in it. */
> } intvl; /* Interval histogram data. */
> } hdata; /* Profiled information specific data. */
> };
>
>
> After my best effor so far:
>
> struct histogram_value_t GTY(())
> {
> struct
> { /* <--- line 48, error below occurs here */
> tree value; /* The value to profile. */
> tree stmt; /* Insn containing the value. */
> gcov_type *counters; /* Pointer to first counter. */
> struct histogram_value_t GTY((chain_next("%h.next")) *next; /*
> Linked list pointer. */
> } hvalue;
> enum hist_type type; /* Type of information to measure. */
> unsigned n_counters; /* Number of required counters. */
> union
> {
> struct
> {
> int int_start; /* First value in interval. */
> unsigned int steps; /* Number of values in it. */
> } intvl; /* Interval histogram data. */
> } GTY ((default("intvl")) hdata; /* Profiled information specific data. */
> };
>
> And this one gives a gengtype error:
>
> ../../gcc-boehm-custom-marking/gcc/value-prof.h:48: syntax error,
> unexpected '*', expecting ')'
>
> What should I do about it?
>
Have to typedef the pointer due to gengtype silliness, IIRC.
IE typedef struct histogram_value_t *histogram_value_t_p;
then use histogram_value_t_p in the structure with the gty marker.