[Gc] Determining alignment constraints

Boehm, Hans hans.boehm at hp.com
Tue May 2 10:21:11 PDT 2006

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).  Getting 16 byte alignment on a 32-bit platform (e.g. X86) may require overallocating and rounding up the pointer, possibly registering a 8 bytes as a valid pointer displacement.  The intent is that GC_malloc should meet alignment requirements for malloc, interpreted fairly strictly, i.e. to not include X86 alignment requirements which are necessary only with nonportable SSE code.

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

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.

> -----Original Message-----
> From: gc-bounces at napali.hpl.hp.com 
> [mailto:gc-bounces at napali.hpl.hp.com] On Behalf Of Ludovic Courtès
> Sent: Tuesday, May 02, 2006 2:02 AM
> To: gc at napali.hpl.hp.com
> Subject: [Gc] Determining alignment constraints
> Hi,
> Is there a way for programs that use `libgc' to know (preferably at
> compile-time) under what alignment constraints `GC_malloc ()' 
> et al. work?  For instance, it can be useful to know whether 
> `GC_malloc ()'
> always return 8-octet aligned memory chunks, as with `ALIGN_DOUBLE'
> defined.
> Thanks,
> Ludovic.
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> https://www.hpl.hp.com/hosted/linux/mail-archives/gc/

More information about the Gc mailing list