diff options
Diffstat (limited to 'src/wrapped')
| -rw-r--r-- | src/wrapped/wrappedglib2.c | 41 |
1 files changed, 39 insertions, 2 deletions
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 <stdlib.h> #include <string.h> #include <dlfcn.h> +#include <stdarg.h> #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); } |