From 9044e133098f04a99a1731f3a544bd469153fc52 Mon Sep 17 00:00:00 2001 From: "W. J. van der Laan" Date: Sun, 4 Apr 2021 11:24:36 +0000 Subject: [PATCH] lib: Make stdarg work for GCC on RISC-V64. * include/stdarg.h: GCC on RISC-V always passes arguments in registers. Implementing these macros without the use of built-ins would be very involved. So use those for now to make printf etc work. --- include/stdarg.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/stdarg.h b/include/stdarg.h index 6a8fee6a..5e4f5533 100644 --- a/include/stdarg.h +++ b/include/stdarg.h @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -26,7 +27,19 @@ #define va_arg8(ap, type) va_arg(ap, type) -#else // ! SYSTEM_LIBC +#elif __GNUC__ && __riscv + +// GCC on RISC-V always passes arguments in registers. Implementing these macros without +// the use of built-ins would be very involved. +typedef __builtin_va_list va_list; + +#define va_start(v,l) __builtin_va_start(v,l) +#define va_end(v) __builtin_va_end(v) +#define va_arg(v,l) __builtin_va_arg(v,l) +#define va_arg8(ap, type) va_arg(ap, type) +#define va_copy(d,s) __builtin_va_copy(d,s) + +#else // ! SYSTEM_LIBC && ! __riscv #include