Skip to content

Commit

Permalink
more Win64 varargs issues
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Sep 23, 2012
1 parent d5fef2d commit a20b018
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
18 changes: 9 additions & 9 deletions internal/gc/gc.d
Original file line number Diff line number Diff line change
Expand Up @@ -1278,14 +1278,14 @@ byte[] _d_arraycatnT(TypeInfo ti, uint n, ...)
}
}
else version (Win64)
{
auto p = cast(byte[]*)(&n + 1);
{{
auto p = cast(byte[]**)(cast(void*)&n + 8);
for (uint i = 0; i < n; i++)
{
byte[] b = *p++;
length += b.length;
byte[]* b = *p++;
length += (*b).length;
}
}
}}
else
{
__va_list argsave = __va_argsave.va;
Expand Down Expand Up @@ -1322,19 +1322,19 @@ byte[] _d_arraycatnT(TypeInfo ti, uint n, ...)
}
}
else version (Win64)
{
p = cast(byte[]*)(&n + 1);
{{
auto p = cast(byte[]**)(cast(void*)&n + 8);
size_t j = 0;
for (uint i = 0; i < n; i++)
{
byte[] b = *p++;
byte[] b = *(*p++);
if (b.length)
{
memcpy(a + j, b.ptr, b.length * sizeelem);
j += b.length * sizeelem;
}
}
}
}}
else
{
va_list ap2 = &argsave;
Expand Down
34 changes: 30 additions & 4 deletions std/format.d
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,8 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
{
//printf("\nputArray(len = %u), tsize = %u\n", len, valti.tsize());
putc('[');
//ubyte*b = cast(ubyte*)p;
//printf(" %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8], b[9]);
valti = skipCI(valti);
size_t tsize = valti.tsize();
auto argptrSave = argptr;
Expand All @@ -651,9 +653,16 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
//doFormat(putc, (&valti)[0 .. 1], p);
version (Win64)
{
argptr = p;
void* q = void;

if (tsize > 8 && m != Mangle.Tsarray)
{ q = p;
argptr = &q;
}
else
argptr = p;
formatArg('s');
p += size_t.sizeof;
p += tsize;
}
else
{
Expand Down Expand Up @@ -704,32 +713,49 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
void* pvalue = pkey + keysizet;

//doFormat(putc, (&keyti)[0..1], pkey);
m = getMan(keyti);
version (X86)
argptr = pkey;
else version (Win64)
{
void* q = void;
if (keysize > 8 && m != Mangle.Tsarray)
{ q = pkey;
argptr = &q;
}
else
argptr = pkey;
}
else
{ __va_list va;
va.stack_args = pkey;
argptr = &va;
}
ti = keyti;
m = getMan(keyti);
formatArg('s');

putc(':');
//doFormat(putc, (&valti)[0..1], pvalue);
m = getMan(valti);
version (X86)
argptr = pvalue;
else version (Win64)
{
void* q2 = void;
auto valuesize = valti.tsize();
if (valuesize > 8 && m != Mangle.Tsarray)
{ q2 = pvalue;
argptr = &q2;
}
else
argptr = pvalue;
}
else
{ __va_list va2;
va2.stack_args = pvalue;
argptr = &va2;
}
ti = valti;
m = getMan(valti);
formatArg('s');
}
m = mSave;
Expand Down

0 comments on commit a20b018

Please sign in to comment.