[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Alignment issue?
From: |
Richard Frith-Macdonald |
Subject: |
Re: Alignment issue? |
Date: |
Sat, 6 Jul 2013 08:58:09 +0100 |
On 5 Jul 2013, at 14:41, Laurent Michel <address@hidden> wrote:
> Ok, so that's a bug then. On x64, one should add 8 bytes of padding before
> (or after) the counter in front of any NSObject to preserve a clean
> alignment.
NSAllocateObject() already contained code to do that, but was getting it wrong
using the alignment of double.
With gcc it can use __BIGGEST_ALIGNMENT__ to get the right calculation, but
that's not available with clang.
So I changed the code in svn trunk to always use 16 if we are compiling with
clang.
If anyone knows a clang equiivalent of __BIGGEST_ALIGNMENT__, we could/should
change to use it, since using 16 may waste space on some architectures and may
not be enough on others (though I know of none).
PS. this is for NSAllocateObject() ... if you call class_createInstance() then
the runtime will probably not provide the required padding :-(
However, if you are using the old runtime, the compatibility layer in
gnustep-base now implements class_createInstance() by calling
NSDAllocateObject(), so in this case it should be safe to use that runtime
function.