From 2e31b7160b365ec151f2149bd06afa7ec65f4483 Mon Sep 17 00:00:00 2001 From: Julgodis <> Date: Sat, 25 Sep 2021 23:39:41 +0200 Subject: [PATCH] OK va_list, va_start, va_arg, and va_end --- include/Runtime.PPCEABI.H/__va_arg.h | 28 ++++++++++++++++++++++++ libs/JSystem/JUtility/JUTDirectPrint.cpp | 1 + libs/Runtime.PPCEABI.H/__va_arg.cpp | 6 ++--- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/include/Runtime.PPCEABI.H/__va_arg.h b/include/Runtime.PPCEABI.H/__va_arg.h index 3e6751e43f2..aed93a5e332 100644 --- a/include/Runtime.PPCEABI.H/__va_arg.h +++ b/include/Runtime.PPCEABI.H/__va_arg.h @@ -3,4 +3,32 @@ #include "dolphin/types.h" +// not sure what the members are. OK when the struct is 12 bytes. +typedef struct __va_list_struct { + u8 data[12]; +}; + +typedef __va_list_struct __va_list[1]; + +extern "C" void __va_arg(void*, int); + +#if IN_VSCODE_EDITOR +#define __builtin_va_info(...) +#define _var_arg_typeof(...) +#endif + + +// from defined-string in mwcceppc.exe: +// __builtin_va_info: initialize the __va_list_struct +// _var_arg_typeof: convert type to integer for __va_arg +#define __va_start(list, fmt) __builtin_va_info(&list) +#define __va_arg(list, type) (*((type*)__va_arg(ap, _var_arg_typeof(type)))) +#define va_start __va_start +#define va_arg __va_arg +#define va_end __va_end +#define va_list __va_list +#define __va_end(list) ((void)0) + +#define __va_copy(a, b) (*(a) = *(b)) + #endif /* __VA_ARG_H */ diff --git a/libs/JSystem/JUtility/JUTDirectPrint.cpp b/libs/JSystem/JUtility/JUTDirectPrint.cpp index 9433ba74fff..9a5903bf20d 100644 --- a/libs/JSystem/JUtility/JUTDirectPrint.cpp +++ b/libs/JSystem/JUtility/JUTDirectPrint.cpp @@ -9,6 +9,7 @@ #include "dolphin/types.h" #include "global.h" #include "msl_c/string.h" +#include "Runtime.PPCEABI.H/__va_arg.h" // // Types: diff --git a/libs/Runtime.PPCEABI.H/__va_arg.cpp b/libs/Runtime.PPCEABI.H/__va_arg.cpp index 78faba4ca61..968677be658 100644 --- a/libs/Runtime.PPCEABI.H/__va_arg.cpp +++ b/libs/Runtime.PPCEABI.H/__va_arg.cpp @@ -7,12 +7,12 @@ #include "dol2asm.h" #include "dolphin/types.h" +#undef __va_arg + // // Forward References: // -extern "C" void __va_arg(); - // // External References: // @@ -25,7 +25,7 @@ extern "C" void __va_arg(); #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void __va_arg() { +asm void __va_arg(void*, int) { nofralloc #include "asm/Runtime.PPCEABI.H/__va_arg/__va_arg.s" }