diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2025-07-04 23:02:20 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2025-07-04 23:02:20 +0200 |
| commit | b4d43748e5d9edc842e3b573f26b2578a32cda54 (patch) | |
| tree | 6309b757e0abc182f35a79b6ec3464e54f38d1ec /src | |
| parent | 549b384c3c203bc949d86ff73e0134f6973e1e0a (diff) | |
| download | box64-b4d43748e5d9edc842e3b573f26b2578a32cda54.tar.gz box64-b4d43748e5d9edc842e3b573f26b2578a32cda54.zip | |
[WRAPPER] Added a couple of libc/libm wrapped functions (for #2796)
Diffstat (limited to 'src')
| -rw-r--r-- | src/emu/x64printer.c | 2 | ||||
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 2 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedlibctypes.h | 1 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.c | 5 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.h | 1 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibc.c | 12 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibc_private.h | 2 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibm_private.h | 2 |
8 files changed, 14 insertions, 13 deletions
diff --git a/src/emu/x64printer.c b/src/emu/x64printer.c index 64468f01..09f2f31f 100644 --- a/src/emu/x64printer.c +++ b/src/emu/x64printer.c @@ -99,6 +99,8 @@ void x64Print(x64emu_t* emu, char* buff, size_t buffsz, const char* func, int ti snprintf(buff, buffsz, "%04d|%p: Calling %s(%" PRIf ")", tid, *(void**)(R_RSP), func, emu->xmm[0].f[0]); } else if (w == IFd) { snprintf(buff, buffsz, "%04d|%p: Calling %s(%" PRIf ")", tid, *(void**)(R_RSP), func, emu->xmm[0].d[0]); + } else if (w == IFD) { + snprintf(buff, buffsz, "%04d|%p: Calling %s(%" PRILf ")", tid, *(void**)(R_RSP), func, LD2localLD((void*)(R_RSP + 8))); } else if (w == IFp) { snprintf(buff, buffsz, "%04d|%p: Calling %s(%" PRIp ")", tid, *(void**)(R_RSP), func, (void*)R_RDI); } else if (w == CFv) { diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index 47de184f..ad4fef3c 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -45,6 +45,7 @@ #() IFI #() IFf #() IFd +#() IFD #() IFp #() IFS #() CFv @@ -4815,6 +4816,7 @@ wrappedlibc: - vsnprintf - vswprintf - iFppii: + - nftw - nftw64 - iFpppp: - __register_atfork diff --git a/src/wrapped/generated/wrappedlibctypes.h b/src/wrapped/generated/wrappedlibctypes.h index 9722b455..980283af 100644 --- a/src/wrapped/generated/wrappedlibctypes.h +++ b/src/wrapped/generated/wrappedlibctypes.h @@ -306,6 +306,7 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void* GO(__vsnprintf, iFpLpA_t) \ GO(vsnprintf, iFpLpA_t) \ GO(vswprintf, iFpLpA_t) \ + GO(nftw, iFppii_t) \ GO(nftw64, iFppii_t) \ GO(__register_atfork, iFpppp_t) \ GO(__vsprintf_chk, iFpppp_t) \ diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index 79de8b48..520cf020 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -3506,6 +3506,7 @@ typedef int32_t (*iFpppppppppppppppppppppppppppppppppp_t)(void*, void*, void*, v #if defined(HAVE_LD80BITS) || defined(ANDROID) typedef int32_t (*iFD_t)(long double); +typedef int64_t (*IFD_t)(long double); typedef long double (*DFD_t)(long double); typedef long double (*DFY_t)(complexl_t); typedef intptr_t (*lFD_t)(long double); @@ -3531,6 +3532,7 @@ typedef int32_t (*iFDipppL_t)(long double, int32_t, void*, void*, void*, uintptr typedef void (*vFppippDpDc_t)(void*, void*, int32_t, void*, void*, long double, void*, long double, int8_t); #else // !HAVE_LD80BITS && !ANDROID typedef int32_t (*iFD_t)(double); +typedef int64_t (*IFD_t)(double); typedef double (*DFD_t)(double); typedef double (*DFY_t)(complex_t); typedef intptr_t (*lFD_t)(double); @@ -7041,6 +7043,7 @@ void iFpppppppppppppppppppppppppppppppppp(x64emu_t *emu, uintptr_t fcn) { iFpppp #if defined(ANDROID) void iFD(x64emu_t *emu, uintptr_t fcn) { iFD_t fn = (iFD_t)fcn; R_RAX=(uint32_t)fn(*(long double*)&emu->xmm[0]); } +void IFD(x64emu_t *emu, uintptr_t fcn) { IFD_t fn = (IFD_t)fcn; S_RAX=(int64_t)fn(*(long double*)&emu->xmm[0]); } void DFD(x64emu_t *emu, uintptr_t fcn) { DFD_t fn = (DFD_t)fcn; long double ld=fn(*(long double*)&emu->xmm[0]); emu->xmm[0].u128=*(__uint128_t*)&ld; } void DFY(x64emu_t *emu, uintptr_t fcn) { DFY_t fn = (DFY_t)fcn; long double ld=fn(to_complexl(emu, (uintptr_t)&emu->xmm[0])); emu->xmm[0].u128=*(__uint128_t*)&ld; } void lFD(x64emu_t *emu, uintptr_t fcn) { lFD_t fn = (lFD_t)fcn; R_RAX=(intptr_t)fn(*(long double*)&emu->xmm[0]); } @@ -7066,6 +7069,7 @@ void iFDipppL(x64emu_t *emu, uintptr_t fcn) { iFDipppL_t fn = (iFDipppL_t)fcn; R void vFppippDpDc(x64emu_t *emu, uintptr_t fcn) { vFppippDpDc_t fn = (vFppippDpDc_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (void*)R_R8, *(long double*)&emu->xmm[0], (void*)R_R9, *(long double*)&emu->xmm[1], *(int8_t*)(R_RSP + 8)); } #elif !defined(HAVE_LD80BITS) void iFD(x64emu_t *emu, uintptr_t fcn) { iFD_t fn = (iFD_t)fcn; R_RAX=(uint32_t)fn(FromLD((void*)(R_RSP + 8))); } +void IFD(x64emu_t *emu, uintptr_t fcn) { IFD_t fn = (IFD_t)fcn; S_RAX=(int64_t)fn(FromLD((void*)(R_RSP + 8))); } void DFD(x64emu_t *emu, uintptr_t fcn) { DFD_t fn = (DFD_t)fcn; double db=fn(FromLD((void*)(R_RSP + 8))); fpu_do_push(emu); ST0val = db; } void DFY(x64emu_t *emu, uintptr_t fcn) { DFY_t fn = (DFY_t)fcn; double db=fn(to_complexk(emu, R_RSP + 8)); fpu_do_push(emu); ST0val = db; } void lFD(x64emu_t *emu, uintptr_t fcn) { lFD_t fn = (lFD_t)fcn; R_RAX=(intptr_t)fn(FromLD((void*)(R_RSP + 8))); } @@ -7091,6 +7095,7 @@ void iFDipppL(x64emu_t *emu, uintptr_t fcn) { iFDipppL_t fn = (iFDipppL_t)fcn; R void vFppippDpDc(x64emu_t *emu, uintptr_t fcn) { vFppippDpDc_t fn = (vFppippDpDc_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (void*)R_R8, FromLD((void*)(R_RSP + 8)), (void*)R_R9, FromLD((void*)(R_RSP + 24)), *(int8_t*)(R_RSP + 40)); } #else // defined(HAVE_LD80BITS) && !defined(ANDROID) void iFD(x64emu_t *emu, uintptr_t fcn) { iFD_t fn = (iFD_t)fcn; R_RAX=(uint32_t)fn(LD2localLD((void*)(R_RSP + 8))); } +void IFD(x64emu_t *emu, uintptr_t fcn) { IFD_t fn = (IFD_t)fcn; S_RAX=(int64_t)fn(LD2localLD((void*)(R_RSP + 8))); } void DFD(x64emu_t *emu, uintptr_t fcn) { DFD_t fn = (DFD_t)fcn; long double ld=fn(LD2localLD((void*)(R_RSP + 8))); fpu_do_push(emu); ST0val = ld; } void DFY(x64emu_t *emu, uintptr_t fcn) { DFY_t fn = (DFY_t)fcn; long double ld=fn(to_complexl(emu, R_RSP + 8)); fpu_do_push(emu); ST0val = ld; } void lFD(x64emu_t *emu, uintptr_t fcn) { lFD_t fn = (lFD_t)fcn; R_RAX=(intptr_t)fn(LD2localLD((void*)(R_RSP + 8))); } diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index ce9da9ee..f1591123 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -82,6 +82,7 @@ void IFi(x64emu_t *emu, uintptr_t fnc); void IFI(x64emu_t *emu, uintptr_t fnc); void IFf(x64emu_t *emu, uintptr_t fnc); void IFd(x64emu_t *emu, uintptr_t fnc); +void IFD(x64emu_t *emu, uintptr_t fnc); void IFp(x64emu_t *emu, uintptr_t fnc); void IFS(x64emu_t *emu, uintptr_t fnc); void CFv(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index b6e05fb3..f5a2771f 100644 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -2171,17 +2171,6 @@ EXPORT int32_t my_ftw(x64emu_t* emu, void* pathname, void* B, int32_t nopenfd) return f(pathname, findftwFct(B), nopenfd); } -EXPORT int32_t my_nftw(x64emu_t* emu, void* pathname, void* B, int32_t nopenfd, int32_t flags) -{ - static iFppii_t f = NULL; - if(!f) { - library_t* lib = my_lib; - if(!lib) return 0; - f = (iFppii_t)dlsym(lib->w.lib, "nftw"); - } - - return f(pathname, findnftwFct(B), nopenfd, flags); -} #endif #ifndef NOALIGN @@ -2266,6 +2255,7 @@ EXPORT int32_t my_nftw64(x64emu_t* emu, void* pathname, void* B, int32_t nopenfd (void)emu; return nftw64(pathname, findnftw64Fct(B), nopenfd, flags); } +EXPORT int my_nftw(x64emu_t* emu, void* pathname, void* B, int32_t nopenfd, int32_t flags) __attribute__((alias("my_nftw64"))); EXPORT char** my_environ = NULL; EXPORT char** my__environ = NULL; diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h index 72393772..07cf5c54 100644 --- a/src/wrapped/wrappedlibc_private.h +++ b/src/wrapped/wrappedlibc_private.h @@ -1370,7 +1370,7 @@ GO(netname2user, iFppppp) GO(__newlocale, pFipp) GOW(newlocale, pFipp) //GO(nfsservctl, -//GOM(nftw, iFppii) +GOM(nftw, iFEppii) GOM(nftw64, iFEppii) GOW(ngettext, pFppL) GO(nice, iFi) diff --git a/src/wrapped/wrappedlibm_private.h b/src/wrapped/wrappedlibm_private.h index 2c4c2d41..effcf49c 100644 --- a/src/wrapped/wrappedlibm_private.h +++ b/src/wrapped/wrappedlibm_private.h @@ -252,7 +252,7 @@ GOWM(llrintf, IFEf) GOWM(llrintl, IFED) GOW(llround, IFd) GOW(llroundf, IFf) -// llroundl // Weak +GOWD(llroundl, IFD, llround) GOW(log, dFd) GOW(log10, dFd) GOW(log10f, fFf) |