[PATCH] introduce a MALLOC_ALIGNMENT configuration macro
Richard Guenther
richard.guenther@gmail.com
Fri Jun 27 16:50:00 GMT 2008
On Fri, Jun 27, 2008 at 6:14 PM, Olivier Hainque <hainque@adacore.com> wrote:
> Thanks for your constructive feedback Richard.
>
> Richard Guenther wrote:
>> I think we need to be careful here.
>
> Agreed.
>
>> Even if glibc may align to say 16bytes, the user may override
>> glibcs implementation with one aligning only to 4bytes if this is all
>> the ABI guarantees.
>
> Indeed.
>
>> So, IMHO this at least asks for an optimization flag, like
>> --param malloc-alignment=N, not a static configuration.
>
> While adding a parameter is a very nice idea, a per-target
> static default still looks useful to me.
Well, if it is an always correct default, yes.
> We couldn't make the option mandatory, I think, and I don't see an
> existing macro that would be really appropriate as a default in every
> case.
In principle the allocator has to make sure it can serve allocation requests
for any type such that the guaranteed natural alignment required by C
is fulfilled. The maximum natural alignment is specified by the ABI and
would be, for i?86 for example, 4 bytes. For x86_64 it would be 8 bytes.
I don't think setting the default to anything higher than that is safe.
Richard.
More information about the Gcc-patches
mailing list