summaryrefslogtreecommitdiff
path: root/libphobos/libdruntime/core/stdc/stdarg.d
diff options
context:
space:
mode:
Diffstat (limited to 'libphobos/libdruntime/core/stdc/stdarg.d')
-rw-r--r--libphobos/libdruntime/core/stdc/stdarg.d21
1 files changed, 21 insertions, 0 deletions
diff --git a/libphobos/libdruntime/core/stdc/stdarg.d b/libphobos/libdruntime/core/stdc/stdarg.d
index 9a67f2e8e4d..646905eaffb 100644
--- a/libphobos/libdruntime/core/stdc/stdarg.d
+++ b/libphobos/libdruntime/core/stdc/stdarg.d
@@ -47,6 +47,8 @@ version (MIPS32) version = MIPS_Any;
version (MIPS64) version = MIPS_Any;
version (PPC) version = PPC_Any;
version (PPC64) version = PPC_Any;
+version (RISCV32) version = RISCV_Any;
+version (RISCV64) version = RISCV_Any;
version (GNU)
{
@@ -130,6 +132,12 @@ else version (AAPCS64)
{
alias va_list = core.internal.vararg.aarch64.va_list;
}
+else version (RISCV_Any)
+{
+ // The va_list type is void*, according to RISCV Calling Convention
+ // https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc
+ alias va_list = void*;
+}
else
{
alias va_list = char*; // incl. unknown platforms
@@ -259,6 +267,19 @@ T va_arg(T)(ref va_list ap)
ap += T.sizeof.alignUp;
return *p;
}
+ else version (RISCV_Any)
+ {
+ static if (T.sizeof > (size_t.sizeof << 1))
+ auto p = *cast(T**) ap;
+ else
+ {
+ static if (T.alignof == (size_t.sizeof << 1))
+ ap = ap.alignUp!(size_t.sizeof << 1);
+ auto p = cast(T*) ap;
+ }
+ ap += T.sizeof.alignUp;
+ return *p;
+ }
else
static assert(0, "Unsupported platform");
}