Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.

Commit 5621c50

Browse files
committed
Merge remote-tracking branch 'origin/ldc-ltsmaster' into ldc
2 parents fa0c558 + 604394b commit 5621c50

File tree

3 files changed

+63
-11
lines changed

3 files changed

+63
-11
lines changed

src/core/stdc/stdarg.d

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ version ( PPC64 ) version = AnyPPC;
2020

2121
version( ARM )
2222
{
23-
// iOS, tvOS use older APCS variant instead of AAPCS
23+
// iOS uses older APCS variant instead of AAPCS
2424
version( iOS ) {}
25-
else version( TVOS ) {}
2625
else version = AAPCS;
2726
}
2827
version( AArch64 )
2928
{
29+
// iOS, tvOS are AAPCS64, but don't follow it for va_list
3030
version( iOS ) {}
3131
else version( TVOS ) {}
3232
else version = AAPCS64;
@@ -336,6 +336,38 @@ version( LDC )
336336
{
337337
alias va_list = __va_list;
338338
}
339+
else version (ARM)
340+
{
341+
// __va_list will be defined for ARM AAPCS targets that need
342+
// it by object.d. Use a .ptr property so ARM code below can
343+
// be common
344+
static if (is(__va_list))
345+
{
346+
alias va_list = __va_list;
347+
348+
private ref auto ptr(ref va_list ap) @property
349+
{
350+
return ap.__ap;
351+
}
352+
private auto ptr(ref va_list ap, void* ptr) @property
353+
{
354+
return ap.__ap = ptr;
355+
}
356+
}
357+
else
358+
{
359+
alias va_list = char*;
360+
361+
private ref auto ptr(ref va_list ap) @property
362+
{
363+
return ap;
364+
}
365+
private auto ptr(ref va_list ap, void* ptr) @property
366+
{
367+
return ap = cast(va_list)ptr;
368+
}
369+
}
370+
}
339371
else
340372
{
341373
alias va_list = char*;
@@ -403,10 +435,10 @@ version( LDC )
403435
version( AAPCS )
404436
{
405437
if (T.alignof >= 8)
406-
ap = cast(va_list)((cast(size_t)ap + 7) & ~7);
438+
ap.ptr = cast(void*)((cast(size_t)ap.ptr + 7) & ~7);
407439
}
408-
T arg = *cast(T*)ap;
409-
ap += (T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
440+
T arg = *cast(T*)ap.ptr;
441+
ap.ptr += (T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
410442
return arg;
411443
}
412444
else version( AnyPPC )
@@ -469,10 +501,10 @@ version( LDC )
469501
version( AAPCS )
470502
{
471503
if (T.alignof >= 8)
472-
ap = cast(va_list)((cast(size_t)ap + 7) & ~7);
504+
ap.ptr = cast(void*)((cast(size_t)ap.ptr + 7) & ~7);
473505
}
474-
parmn = *cast(T*)ap;
475-
ap += (T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
506+
parmn = *cast(T*)ap.ptr;
507+
ap.ptr += (T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
476508
}
477509
else
478510
parmn = va_arg!T(ap);
@@ -527,10 +559,10 @@ version( LDC )
527559
version( AAPCS )
528560
{
529561
if (ti.talign >= 8)
530-
ap = cast(va_list)((cast(size_t)ap + 7) & ~7);
562+
ap.ptr = cast(void*)((cast(size_t)ap.ptr + 7) & ~7);
531563
}
532-
auto p = ap;
533-
ap = p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1));
564+
auto p = ap.ptr;
565+
ap.ptr = p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1));
534566
}
535567
else version( AnyPPC )
536568
{

src/ldc/internal/vararg.di

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,12 @@ version (AArch64)
2121
int __vr_offs;
2222
}
2323
}
24+
else version (ARM)
25+
{
26+
// Need std::__va_list for C++ mangling compatability
27+
// section AAPCS 7.1.4
28+
extern (C++, std) struct __va_list
29+
{
30+
void *__ap;
31+
}
32+
}

src/object.d

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ version (LDC)
7575
alias __va_list = ldc.internal.vararg.std.__va_list;
7676
}
7777
}
78+
else version (ARM)
79+
{
80+
// Darwin does not use __va_list
81+
version( iOS ) {}
82+
else version( WatchOS ) {}
83+
else
84+
{
85+
static import ldc.internal.vararg;
86+
alias __va_list = ldc.internal.vararg.std.__va_list;
87+
}
88+
}
7889
}
7990

8091
version (D_ObjectiveC) public import core.attribute : selector;

0 commit comments

Comments
 (0)