about summary refs log tree commit diff stats
path: root/src/libtools
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-08-30 13:22:38 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-08-30 13:22:48 +0200
commit3fb50522232028e55ea97ccbc9a6bd55b031ff08 (patch)
treec72aa2496be3fd1a4ebf3638f26d06e549da1f8d /src/libtools
parent62b93a0785802120250423fcc4acae9a51555126 (diff)
downloadbox64-3fb50522232028e55ea97ccbc9a6bd55b031ff08.tar.gz
box64-3fb50522232028e55ea97ccbc9a6bd55b031ff08.zip
[BOX32] More 32bits wrapped functions and fixes
Diffstat (limited to 'src/libtools')
-rwxr-xr-xsrc/libtools/myalign64_32.c21
-rwxr-xr-xsrc/libtools/threads32.c41
2 files changed, 55 insertions, 7 deletions
diff --git a/src/libtools/myalign64_32.c b/src/libtools/myalign64_32.c
index 0369099e..77418da1 100755
--- a/src/libtools/myalign64_32.c
+++ b/src/libtools/myalign64_32.c
@@ -4,6 +4,7 @@
 #include <stdint.h>
 #include <asm/stat.h>
 #include <sys/vfs.h>
+#include <sys/statvfs.h>
 
 #include "x64emu.h"
 #include "emu/x64emu_private.h"
@@ -77,6 +78,26 @@ void UnalignStatFS64_32(const void* source, void* dest)
     i386st->f_spare[2]  = st->f_spare[2];
     i386st->f_spare[3]  = st->f_spare[3];
 }
+
+void UnalignStatVFS64_32(const void* source, void* dest)
+{
+    struct i386_statvfs64 *i386st = (struct i386_statvfs64*)dest;
+    struct statvfs *st = (struct statvfs*) source;
+
+    i386st->f_bsize     = st->f_bsize;
+    i386st->f_frsize    = st->f_frsize;
+    i386st->f_blocks    = st->f_blocks;
+    i386st->f_bfree     = st->f_bfree;
+    i386st->f_bavail    = st->f_bavail;
+    i386st->f_files     = st->f_files;
+    i386st->f_ffree     = st->f_ffree;
+    i386st->f_favail    = st->f_favail;
+    i386st->f_fsid      = st->f_fsid;
+    i386st->f_flag      = st->f_flag;
+    i386st->f_namemax   = st->f_namemax;
+    i386st->f_type      = st->f_type;
+}
+
 #define TRANSFERT   \
 GO(l_type)          \
 GO(l_whence)        \
diff --git a/src/libtools/threads32.c b/src/libtools/threads32.c
index bab4cf4f..72229d70 100755
--- a/src/libtools/threads32.c
+++ b/src/libtools/threads32.c
@@ -490,11 +490,24 @@ static void del_cond(void* cond)
 }
 pthread_mutex_t* getAlignedMutex(pthread_mutex_t* m);
 
+EXPORT int my32_pthread_cond_broadcast(x64emu_t* emu, void* cond)
+{
+	pthread_cond_t * c = get_cond(cond);
+	return pthread_cond_broadcast(c);
+}
 EXPORT int my32_pthread_cond_broadcast_old(x64emu_t* emu, void* cond)
 {
 	pthread_cond_t * c = get_cond(cond);
 	return pthread_cond_broadcast(c);
 }
+
+EXPORT int my32_pthread_cond_destroy(x64emu_t* emu, void* cond)
+{
+	pthread_cond_t * c = get_cond(cond);
+	int ret = pthread_cond_destroy(c);
+	if(c!=cond) del_cond(cond);
+	return ret;
+}
 EXPORT int my32_pthread_cond_destroy_old(x64emu_t* emu, void* cond)
 {
 	pthread_cond_t * c = get_cond(cond);
@@ -502,16 +515,29 @@ EXPORT int my32_pthread_cond_destroy_old(x64emu_t* emu, void* cond)
 	if(c!=cond) del_cond(cond);
 	return ret;
 }
+
+EXPORT int my32_pthread_cond_init(x64emu_t* emu, void* cond, void* attr)
+{
+	pthread_cond_t *c = add_cond(cond);
+	return pthread_cond_init(c, (const pthread_condattr_t*)attr);
+}
 EXPORT int my32_pthread_cond_init_old(x64emu_t* emu, void* cond, void* attr)
 {
 	pthread_cond_t *c = add_cond(cond);
 	return pthread_cond_init(c, (const pthread_condattr_t*)attr);
 }
+
+EXPORT int my32_pthread_cond_signal(x64emu_t* emu, void* cond)
+{
+	pthread_cond_t * c = get_cond(cond);
+	return pthread_cond_signal(c);
+}
 EXPORT int my32_pthread_cond_signal_old(x64emu_t* emu, void* cond)
 {
 	pthread_cond_t * c = get_cond(cond);
 	return pthread_cond_signal(c);
 }
+
 EXPORT int my32_pthread_cond_timedwait_old(x64emu_t* emu, void* cond, void* mutex, void* abstime)
 {
 	pthread_cond_t * c = get_cond(cond);
@@ -525,11 +551,13 @@ EXPORT int my32_pthread_cond_wait_old(x64emu_t* emu, void* cond, void* mutex)
 
 EXPORT int my32_pthread_cond_timedwait(x64emu_t* emu, void* cond, void* mutex, void* abstime)
 {
-	return pthread_cond_timedwait((pthread_cond_t*)cond, getAlignedMutex((pthread_mutex_t*)mutex), (const struct timespec*)abstime);
+	pthread_cond_t * c = get_cond(cond);
+	return pthread_cond_timedwait(c, getAlignedMutex((pthread_mutex_t*)mutex), (const struct timespec*)abstime);
 }
 EXPORT int my32_pthread_cond_wait(x64emu_t* emu, void* cond, void* mutex)
 {
-	return pthread_cond_wait((pthread_cond_t*)cond, getAlignedMutex((pthread_mutex_t*)mutex));
+	pthread_cond_t * c = get_cond(cond);
+	return pthread_cond_wait(c, getAlignedMutex((pthread_mutex_t*)mutex));
 }
 
 EXPORT int my32_pthread_mutexattr_setkind_np(x64emu_t* emu, void* t, int kind)
@@ -644,15 +672,14 @@ EXPORT int my32_pthread_attr_setschedpolicy(x64emu_t* emu, void* attr, int p)
 }
 EXPORT int my32_pthread_attr_setstackaddr(x64emu_t* emu, void* attr, void* p)
 {
-	ulong_t size = 2*1024*1024;
-	my32_pthread_attr_getstacksize(emu, attr, &size);
+	size_t size = 2*1024*1024;
+	void* pp;
+	pthread_attr_getstack(get_attr(attr), &pp, &size);
 	return pthread_attr_setstack(get_attr(attr), p, size);
 }
 EXPORT int my32_pthread_attr_setstacksize(x64emu_t* emu, void* attr, size_t p)
 {
-	ptr_t pp;
-	my32_pthread_attr_getstackaddr(emu, attr, &pp);
-	return pthread_attr_setstack(get_attr(attr), from_ptrv(pp), p);
+	return pthread_attr_setstacksize(get_attr(attr), p);
 }