[Gc] Re: Determining alignment constraints

Ludovic Courtès ludovic.courtes at laas.fr
Wed May 3 01:40:01 PDT 2006


"Boehm, Hans" <hans.boehm at hp.com> writes:

> In the 6.X versions, this is unfortunately a bit platform dependent.
> ALIGN_DOUBLE should be defined on all platforms which might need 2
> word alignment for standard C types.  If that's not the case, let me
> know (ideally by sending a patch to gcconfig.h).

Actually, I don't mind if it's platform-specific.  What I want is to be
able to know for sure at compilation-time of my user program what the
alignment constraints of the available `libgc' are.

Ideally, the `ALIGNMENT' macro would be exported and documented, for
instance under the name `GC_MALLOC_ALIGNMENT'.  That would be very
useful for programs that need this piece of information.

To give an example, Guile's type mechanism requires that some objects
(namely cells) be 8-octet aligned.  So it needs to know whether
`GC_malloc ()' will honor this alignment constraint, or whether it needs
to over-allocate memory and return an adequately aligned pointer.

> For 6.X, in some common configurations, GC_malloc(4) returns an object
> that's only word aligned, even with ALIGN_DOUBLE set.

According to `gcconfig.h', that is currently limited to m68k, PPC with
MacOS, and CRIS.

> In 7.0alpha, all allocation is performed in units of granules, which
> are normally 2 words, but could be adjusted at GC build time.
> Everything is at least granule aligned.

On a single machine, there may be several programs using the same
`libgc'.  Thus, they should preferably be able to adapt to the
configuration of the available `libgc', rather than relying on some
particular compile-time configuration of `libgc'.


More information about the Gc mailing list