diff options
| author | Leslie Zhai <zhaixiang@loongson.cn> | 2024-11-14 23:01:36 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-14 16:01:36 +0100 |
| commit | 12f4afcba28931ea6f367e11abc2f27ba68ee7f9 (patch) | |
| tree | 4dc742c23ba83f85b9614cc0c800d197f62b89f9 /src/wrapped | |
| parent | cd2638d11a1ce7d1db868e47953740ac540c40ee (diff) | |
| download | box64-12f4afcba28931ea6f367e11abc2f27ba68ee7f9.tar.gz box64-12f4afcba28931ea6f367e11abc2f27ba68ee7f9.zip | |
[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)
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); } |