Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions src/core/stdc/stdarg.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ module core.stdc.stdarg;
version ( PPC ) version = AnyPPC;
version ( PPC64 ) version = AnyPPC;

version( ARM )
{
// iOS, tvOS use older APCS variant instead of AAPCS
version( iOS ) {}
else version( TVOS ) {}
else version = AAPCS;
}

version( X86_64 )
{
// Determine if type is a vector type
Expand Down Expand Up @@ -287,8 +295,6 @@ version( X86_64 )

version( LDC )
{
// FIXME: This isn't actually tested at all for ARM.

version( X86_64 )
{
version( Win64 ) {}
Expand Down Expand Up @@ -357,6 +363,13 @@ version( LDC )
}
else version( ARM )
{
// AAPCS sec 5.5 B.5: type with alignment >= 8 is 8-byte aligned
// instead of normal 4-byte alignment (APCS doesn't do this).
version( AAPCS )
{
if (T.alignof >= 8)
ap = cast(va_list)((cast(size_t)ap + 7) & ~7);
}
T arg = *cast(T*)ap;
ap += (T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
return arg;
Expand Down Expand Up @@ -407,6 +420,13 @@ version( LDC )
}
else version( ARM )
{
// AAPCS sec 5.5 B.5: type with alignment >= 8 is 8-byte aligned
// instead of normal 4-byte alignment (APCS doesn't do this).
version( AAPCS )
{
if (T.alignof >= 8)
ap = cast(va_list)((cast(size_t)ap + 7) & ~7);
}
parmn = *cast(T*)ap;
ap += (T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
}
Expand Down Expand Up @@ -449,9 +469,13 @@ version( LDC )
}
else version( ARM )
{
// Wait until everyone updates to get TypeInfo.talign
//auto talign = ti.talign;
//auto p = cast(va_list) ((cast(size_t)ap + talign - 1) & ~(talign - 1));
// AAPCS sec 5.5 B.5: type with alignment >= 8 is 8-byte aligned
// instead of normal 4-byte alignment (APCS doesn't do this).
version( AAPCS )
{
if (ti.talign >= 8)
ap = cast(va_list)((cast(size_t)ap + 7) & ~7);
}
auto p = ap;
ap = p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1));
}
Expand Down