about summary refs log tree commit diff stats
path: root/src/wrapped/wrappedlibc.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-03-28 15:54:51 +0200
committerptitSeb <sebastien.chev@gmail.com>2021-03-28 15:54:51 +0200
commitee561da549fb6f47f4b301466f2f751a085fa6d5 (patch)
tree5920f59269141614587511701bf5c9a30628f027 /src/wrapped/wrappedlibc.c
parentba1493857f16f8d8e9eec8f3d421e49784761e8d (diff)
downloadbox64-ee561da549fb6f47f4b301466f2f751a085fa6d5.tar.gz
box64-ee561da549fb6f47f4b301466f2f751a085fa6d5.zip
Added more libc and pthreads wrapped functions
Diffstat (limited to 'src/wrapped/wrappedlibc.c')
-rwxr-xr-xsrc/wrapped/wrappedlibc.c77
1 files changed, 8 insertions, 69 deletions
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index 529a2f70..a52fd186 100755
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -159,40 +159,15 @@ static void* findcompareFct(void* fct)
     printf_log(LOG_NONE, "Warning, no more slot for libc compare callback\n");
     return NULL;
 }
-#if 0
-
-// ftw
-#define GO(A)   \
-static uintptr_t my_ftw_fct_##A = 0;                                      \
-static int my_ftw_##A(void* fpath, void* sb, int flag)                       \
-{                                                                               \
-    return (int)RunFunction(my_context, my_ftw_fct_##A, 3, fpath, sb, flag);   \
-}
-SUPER()
-#undef GO
-static void* findftwFct(void* fct)
-{
-    if(!fct) return NULL;
-    void* p;
-    if((p = GetNativeFnc((uintptr_t)fct))) return p;
-    #define GO(A) if(my_ftw_fct_##A == (uintptr_t)fct) return my_ftw_##A;
-    SUPER()
-    #undef GO
-    #define GO(A) if(my_ftw_fct_##A == 0) {my_ftw_fct_##A = (uintptr_t)fct; return my_ftw_##A; }
-    SUPER()
-    #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for libc ftw callback\n");
-    return NULL;
-}
 
 // ftw64
 #define GO(A)   \
 static uintptr_t my_ftw64_fct_##A = 0;                      \
 static int my_ftw64_##A(void* fpath, void* sb, int flag)    \
 {                                                           \
-    struct i386_stat64 i386st;                              \
-    UnalignStat64(sb, &i386st);                             \
-    return (int)RunFunction(my_context, my_ftw64_fct_##A, 3, fpath, &i386st, flag);  \
+    struct x64_stat64 x64st;                                \
+    UnalignStat64(sb, &x64st);                              \
+    return (int)RunFunction(my_context, my_ftw64_fct_##A, 3, fpath, &x64st, flag);  \
 }
 SUPER()
 #undef GO
@@ -209,38 +184,14 @@ static void* findftw64Fct(void* fct)
     return NULL;
 }
 
-// nftw
-#define GO(A)   \
-static uintptr_t my_nftw_fct_##A = 0;                                   \
-static int my_nftw_##A(void* fpath, void* sb, int flag, void* ftwbuff)  \
-{                                                                       \
-    return (int)RunFunction(my_context, my_nftw_fct_##A, 4, fpath, sb, flag, ftwbuff);   \
-}
-SUPER()
-#undef GO
-static void* findnftwFct(void* fct)
-{
-    if(!fct) return NULL;
-    void* p;
-    if((p = GetNativeFnc((uintptr_t)fct))) return p;
-    #define GO(A) if(my_nftw_fct_##A == (uintptr_t)fct) return my_nftw_##A;
-    SUPER()
-    #undef GO
-    #define GO(A) if(my_nftw_fct_##A == 0) {my_nftw_fct_##A = (uintptr_t)fct; return my_nftw_##A; }
-    SUPER()
-    #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for libc nftw callback\n");
-    return NULL;
-}
-
 // nftw64
 #define GO(A)   \
 static uintptr_t my_nftw64_fct_##A = 0;                                     \
 static int my_nftw64_##A(void* fpath, void* sb, int flag, void* ftwbuff)    \
 {                                                                           \
-    struct i386_stat64 i386st;                                              \
-    UnalignStat64(sb, &i386st);                                             \
-    return (int)RunFunction(my_context, my_nftw64_fct_##A, 4, fpath, &i386st, flag, ftwbuff);   \
+    struct x64_stat64 x64st;                                              \
+    UnalignStat64(sb, &x64st);                                             \
+    return (int)RunFunction(my_context, my_nftw64_fct_##A, 4, fpath, &x64st, flag, ftwbuff);   \
 }
 SUPER()
 #undef GO
@@ -256,7 +207,7 @@ static void* findnftw64Fct(void* fct)
     printf_log(LOG_NONE, "Warning, no more slot for libc nftw64 callback\n");
     return NULL;
 }
-
+#if 0
 // globerr
 #define GO(A)   \
 static uintptr_t my_globerr_fct_##A = 0;                                        \
@@ -1495,18 +1446,6 @@ EXPORT int my_scandir64(x64emu_t *emu, void* dir, void* namelist, void* sel, voi
 {
     return scandir64(dir, namelist, findfilter64Fct(sel), findcompare64Fct(comp));
 }
-#if 0
-EXPORT int my_scandir(x64emu_t *emu, void* dir, void* namelist, void* sel, void* comp)
-{
-    static iFpppp_t f = NULL;
-    if(!f) {
-        library_t* lib = my_lib;
-        if(!lib) return 0;
-        f = (iFpppp_t)dlsym(lib->priv.w.lib, "scandir");
-    }
-
-    return f(dir, namelist, findfilter_dirFct(sel), findcompare_dirFct(comp));
-}
 
 EXPORT int my_ftw64(x64emu_t* emu, void* filename, void* func, int descriptors)
 {
@@ -1517,7 +1456,7 @@ EXPORT int32_t my_nftw64(x64emu_t* emu, void* pathname, void* B, int32_t nopenfd
 {
     return nftw64(pathname, findnftw64Fct(B), nopenfd, flags);
 }
-#endif
+
 EXPORT int32_t my_execv(x64emu_t* emu, const char* path, char* const argv[])
 {
     int self = isProcSelf(path, "exe");