This is the mail archive of the gcc@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]

Re: typed gengtype & GCC plugins for both 4.5 & 4.6 - e.g. MELT


2010/6/15 Basile Starynkevitch <basile@starynkevitch.net>:
> Â /*** NOTE: june 2010.
>
> Â Â Â ÂGCC 4.6 has a new typed garbage collected allocator; so any
> Â Â Â ÂGTY-ed struct FOO_ST should be allocated using ggc_alloc_FOO_ST
> Â Â Â Âor ggc_alloc_cleared_FOO_ST.
> Â ***/
> Â #if BUILDING_GCC_VERSION >= 4006 && defined(ggc_alloc_typed)
> Â #define MELT_HAS_TYPED_GGC_ALLOC 1
> Â #else
> Â #define MELT_HAS_TYPED_GGC_ALLOC 0
> Â #endif
>
> By the way, perhaps defined(ggc_alloc_typed) would be enough above.

There is no guarantee ggc_alloc_typed won't change for 4.7 or even
4.6. If you really want to pursue this, perhaps try checking for a
typed allocator of a well-known GCC data type:
#if defined (ggc_alloc_rtx_def)
...

But then again, it may become a function instead of macro in 4.7,
breaking the test.

> Â#if MELT_HAS_TYPED_GGC_ALLOC
> Â Â Â Âstruct meltobject_st *dst =
> Â Â Â Â Âggc_alloc_cleared_meltobject_st (oblen * sizeof (src->obj_vartab[0]));
> Â#else /*!MELT_HAS_TYPED_GGC_ALLOC*/
> Â Â Â Âstruct meltobject_st *dst = (struct meltobject_st *)
> Â Â Â Â Âggc_alloc_cleared (offsetof (struct meltobject_st,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â obj_vartab) +
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â oblen * sizeof (src->obj_vartab[0]));
> Â#endif /*MELT_HAS_TYPED_GGC_ALLOC*/

I'd say, use a common ggc_alloc_cleared_meltobject_st which is made by
gengtype in 4.6+ and provide its suitable definition yourself for 4.5.

-- 
Laurynas


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