diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-09-26 12:06:01 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-09-26 12:06:01 +0200 |
| commit | 783e9a4b7442506765fe9687d006e0cd17c3c2f1 (patch) | |
| tree | 8f29384177f4fa05f02bdb8c52bbc84d561bc5b3 /src/include | |
| parent | 202a067a6177e4a9d6b31e1089cd81368ae9d4b3 (diff) | |
| download | box64-783e9a4b7442506765fe9687d006e0cd17c3c2f1.tar.gz box64-783e9a4b7442506765fe9687d006e0cd17c3c2f1.zip | |
More untested support for loongarch64 va_list
Diffstat (limited to 'src/include')
| -rwxr-xr-x | src/include/myalign.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/include/myalign.h b/src/include/myalign.h index 1e238d78..4c805049 100755 --- a/src/include/myalign.h +++ b/src/include/myalign.h @@ -102,8 +102,18 @@ typedef struct va_list { #error TODO! #elif defined(__loongarch64) #define CREATE_SYSV_VALIST(A) \ - va_list sysv_vaargs = (va_list)A; + va_list sysv_vaargs = (va_list)A // not creating CONVERT_VALIST(A) on purpose +// this one will create a VA_LIST from x64_va_list using only GPRS and 100 stack element +#define CREATE_VALIST_FROM_VALIST(VA, SCRATCH) \ + va_list sysv_varargs; \ + { \ + uintptr_t *p = (uintptr_t*)(SCRATCH); \ + int n = (X64_VA_MAX_REG - (VA)->gp_offset)/8 \ + if(n) memcpy(&p[0], (VA)->reg_save_area, n*8); \ + memcpy(&p[n], STACK, 100*8); \ + sysv_varargs = (va_list)p; \ + } // this is an approximation, and if the va_list have some float/double, it will fail! // if the funciton needs more than 100 args, it will also fail #define CREATE_VALIST_FROM_VAARG(STACK, SCRATCH, N) \ @@ -113,8 +123,8 @@ typedef struct va_list { p[0]=R_RDI; p[1]=R_RSI; p[2]=R_RDX; \ p[3]=R_RCX; p[4]=R_R8; p[5]=R_R9; \ memcpy(&p[6], STACK, 100*8); \ - sysv_varargs = (void*)&p[N]; \ - } \ + sysv_varargs = (va_list)&p[N]; \ + } #else #error Unknown architecture! #endif |