From 12f4afcba28931ea6f367e11abc2f27ba68ee7f9 Mon Sep 17 00:00:00 2001 From: Leslie Zhai Date: Thu, 14 Nov 2024 23:01:36 +0800 Subject: [LA64] Implement convert x64_va_list_t to sysv_varargs for float (#2025) (#2031) * [LA64] Implement convert x64_va_list_t to sysv_varargs for float (#2025) * [LA64] Implement myStackAlignGVariantNew (#2025) * [LA64] Limit the log to LOG_DEBUG (#2055) * [LA64] Add missing file (#2025) --- src/wrapped/wrappedglib2.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'src/wrapped') diff --git a/src/wrapped/wrappedglib2.c b/src/wrapped/wrappedglib2.c index 210729f0..3a481eff 100644 --- a/src/wrapped/wrappedglib2.c +++ b/src/wrapped/wrappedglib2.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "wrappedlibs.h" @@ -1077,9 +1078,45 @@ EXPORT void* my_g_variant_new_va(x64emu_t* emu, char* fmt, void* endptr, x64_va_ #ifdef CONVERT_VALIST CONVERT_VALIST(*b); #else - CREATE_VALIST_FROM_VALIST(*b, emu->scratch); + #if defined(__loongarch64) || defined(__riscv) + va_list sysv_varargs; + uint64_t scratch[N_SCRATCH]; + myStackAlignGVariantNew(emu, fmt, scratch, b); + sysv_varargs = (va_list)scratch; + #else + CREATE_VALIST_FROM_VALIST(*b, emu->scratch); + #endif #endif - va_list* aligned = &VARARGS; + if (box64_log == LOG_DEBUG) { + printf_log(LOG_DEBUG, "fmt: %s\n", fmt); + const char* pfmt = fmt; + int i = 0; + while (*pfmt) { + switch (*pfmt) { + case 'b': + case 'y': + case 'n': + case 'q': + case 'i': + case 'h': + case 'u': + printf_log(LOG_DEBUG, "%2d: %d\n", i, va_arg(sysv_varargs, int)); + break; + case 'x': + case 't': + printf_log(LOG_DEBUG, "%2d: %ld\n", i, va_arg(sysv_varargs, long)); + break; + case 'd': + printf_log(LOG_DEBUG, "%2d: %f\n", i, va_arg(sysv_varargs, double)); + break; + default: + break; + } + pfmt++; + i++; + } + } + va_list* aligned = &sysv_varargs; return my->g_variant_new_va(fmt, endptr, &aligned); } -- cgit 1.4.1