PATCH: skipping code in gengtype (trunk)
Basile STARYNKEVITCH
basile@starynkevitch.net
Thu Jan 4 15:56:00 GMT 2007
Le Thu, Jan 04, 2007 at 07:16:26AM -0800, Ian Lance Taylor écrivait/wrote:
> Basile STARYNKEVITCH <basile@starynkevitch.net> writes:
>
> > In some occasions [1,2], the gengtype generator behave strangely, and
> > a simple workaround would be to let it skip (i.e. ignore) some code.
> >
> > The attached patch (to rev.120437 of trunk) includes into gengtype the
> > ability to skip code, and documents it.
> >
> > [1] http://gcc.gnu.org/ml/gcc/2007-01/msg00172.html
> > [2] http://gcc.gnu.org/ml/gcc/2003-03/msg01258.html
>
> I don't understand how adding the ability to for gengtype to skip some
> code actually fixes these problems. If you want to put something on
> the heap, gengtype needs to understand what it is.
I just wanted an explicitly managed (hence heap allocated, but not
garbage collected) vector of char* (file paths which are explicitly
strdup-ed). I'm only interested by the VEC API and I don't want ggc or
GTY to know about it - there is no garbage collectable pointers in my
example. In that case, my patch is a suitable workaround (for an
example like [1]).
What I don't understand in the first place is why the example in [1]
don't work (ie why gengtype produces an error). I do admit that my
patch is just a quick and dirty work-around and not a fix, but
apparently it works.
Apparently I might do
typedef void* basilevoid_p;
VEC(basilevoid_p,heap) *basilevoid_vector;
since the free_block_data field in struct dom_walk_data in
gcc/domwalk.h is declared similarily (but this file domwalk.h does not
at all use GTY so is not processed by gengtype).
But it seems difficult to mix heap-allocated (hence explicitly
allocated & freed) vectors of heap allocated pointers (eg.strdup-ed
strings) and GTY-ed vectors in the same file.
Maybe I should use the "none" allocation and code instead for the
example [1]
typedef char* basilestring_t;
DEF_VEC_P (basilestring_t);
DEF_VEC_ALLOC_P (basilestring_t,none);
static VEC(basilestring_t,none) *basilestring_vector;
but the comment in gcc/vec.h says
The ALLOC argument specifies the
allocation strategy, and can be either 'gc' or 'heap' for garbage
collected and heap allocated respectively. It can be 'none' to get
a vector that must be explicitly allocated (for instance as a
trailing array of another structure).
I don't understand if an explicitly allocated VEC pointer of strdup-ed
char* pointers fits into this case.
So I only want to have a VEC of char*, each vector element being an
strdup-ed string. I want to explicitly allocate the vector and each of
it elements, and will explicitly deallocate each element and the whole
vector itself
Regards.
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faïencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***
More information about the Gcc-patches
mailing list