mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-04 18:40:47 +00:00
Memory alignment fix
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6880 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
da1682bc48
commit
1b2e9c1e38
2 changed files with 32 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2000-07-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/GSTcpPort.m: Add code to cope with machines requiring word
|
||||||
|
alignment for memory references.
|
||||||
|
|
||||||
2000-07-05 Richard Frith-Macdonald <rfm@gnu.org>
|
2000-07-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Tools/Makefile.postabmle: Create directory for DTDs if needed
|
* Tools/Makefile.postabmle: Create directory for DTDs if needed
|
||||||
|
|
|
@ -280,9 +280,10 @@ newDataWithEncodedPort(GSTcpPort *port)
|
||||||
if ([addr isEqualToString: @"127.0.0.1"] == YES)
|
if ([addr isEqualToString: @"127.0.0.1"] == YES)
|
||||||
{
|
{
|
||||||
NSArray *a = [[port host] addresses];
|
NSArray *a = [[port host] addresses];
|
||||||
|
unsigned c = [a count];
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < [a count]; i++)
|
for (i = 0; i < c; i++)
|
||||||
{
|
{
|
||||||
addr = [a objectAtIndex: i];
|
addr = [a objectAtIndex: i];
|
||||||
if ([addr isEqualToString: @"127.0.0.1"] == NO)
|
if ([addr isEqualToString: @"127.0.0.1"] == NO)
|
||||||
|
@ -1666,13 +1667,36 @@ static Class tcpPortClass;
|
||||||
[header setLength: hLength + l + h];
|
[header setLength: hLength + l + h];
|
||||||
b = [header mutableBytes];
|
b = [header mutableBytes];
|
||||||
b += hLength;
|
b += hLength;
|
||||||
hLength += l + h;
|
#if NEED_WORD_ALIGNMENT
|
||||||
pih = (GSPortItemHeader*)b;
|
/*
|
||||||
memcpy(b+h, [o bytes], l);
|
* When packing data, an item may not be aligned on a
|
||||||
|
* word boundary, so we work with an aligned buffer
|
||||||
|
* and use memcmpy()
|
||||||
|
*/
|
||||||
|
if ((*hLength % __alignof__(gsu32)) != 0)
|
||||||
|
{
|
||||||
|
GSPortItemHeader itemHeader;
|
||||||
|
|
||||||
|
pih = (GSPortItemHeader*)&itemHeader;
|
||||||
pih->type = GSSwapHostI32ToBig(GSP_DATA);
|
pih->type = GSSwapHostI32ToBig(GSP_DATA);
|
||||||
pih->length = GSSwapHostI32ToBig(l);
|
pih->length = GSSwapHostI32ToBig(l);
|
||||||
|
memcpy(b, (void*)pih, h);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pih = (GSPortItemHeader*)b;
|
||||||
|
pih->type = GSSwapHostI32ToBig(GSP_DATA);
|
||||||
|
pih->length = GSSwapHostI32ToBig(l);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
pih = (GSPortItemHeader*)b;
|
||||||
|
pih->type = GSSwapHostI32ToBig(GSP_DATA);
|
||||||
|
pih->length = GSSwapHostI32ToBig(l);
|
||||||
|
#endif
|
||||||
|
memcpy(b+h, [o bytes], l);
|
||||||
[components removeObjectAtIndex: i--];
|
[components removeObjectAtIndex: i--];
|
||||||
c--;
|
c--;
|
||||||
|
hLength += l + h;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue