mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Alignment fixes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16398 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
87ee43c6dd
commit
b3bd3dc830
5 changed files with 43 additions and 7 deletions
|
@ -378,10 +378,19 @@ failure:
|
|||
|
||||
@implementation NSData
|
||||
|
||||
#if NEED_WORD_ALIGNMENT
|
||||
static unsigned gsu16Align;
|
||||
static unsigned gsu32Align;
|
||||
#endif
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [NSData class])
|
||||
{
|
||||
#if NEED_WORD_ALIGNMENT
|
||||
gsu16Align = objc_alignof_type(@encode(gsu16));
|
||||
gsu32Align = objc_alignof_type(@encode(gsu32));
|
||||
#endif
|
||||
NSDataAbstract = self;
|
||||
NSMutableDataAbstract = [NSMutableData class];
|
||||
dataMalloc = [NSDataMalloc class];
|
||||
|
@ -2615,7 +2624,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
*cursor, length];
|
||||
}
|
||||
#if NEED_WORD_ALIGNMENT
|
||||
if ((*cursor % __alignof__(gsu16)) != 0)
|
||||
if ((*cursor % gsu16Align) != 0)
|
||||
memcpy(&x, (bytes + *cursor), 2);
|
||||
else
|
||||
#endif
|
||||
|
@ -2635,7 +2644,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
*cursor, length];
|
||||
}
|
||||
#if NEED_WORD_ALIGNMENT
|
||||
if ((*cursor % __alignof__(gsu32)) != 0)
|
||||
if ((*cursor % gsu32Align) != 0)
|
||||
memcpy(&x, (bytes + *cursor), 4);
|
||||
else
|
||||
#endif
|
||||
|
@ -3345,7 +3354,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
}
|
||||
*(gsu8*)(bytes + length++) = tag;
|
||||
#if NEED_WORD_ALIGNMENT
|
||||
if ((length % __alignof__(gsu16)) != 0)
|
||||
if ((length % gsu16Align) != 0)
|
||||
{
|
||||
x = GSSwapHostI16ToBig(x);
|
||||
memcpy((bytes + length), &x, 2);
|
||||
|
@ -3366,7 +3375,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
}
|
||||
*(gsu8*)(bytes + length++) = tag;
|
||||
#if NEED_WORD_ALIGNMENT
|
||||
if ((length % __alignof__(gsu32)) != 0)
|
||||
if ((length % gsu32Align) != 0)
|
||||
{
|
||||
x = GSSwapHostI32ToBig(x);
|
||||
memcpy((bytes + length), &x, 4);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue