about summary refs log tree commit diff stats
path: root/src/libtools/threads.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-01-22 16:46:45 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-01-22 16:46:45 +0100
commit07be405f48ab2571d9f14fff0b7dd87e10f17949 (patch)
treeb638e3fc4ad52d88a7c95ce40fc1d393ac4cf305 /src/libtools/threads.c
parent92d5210e3729e6d17c0285383478fe4f1a81602a (diff)
downloadbox64-07be405f48ab2571d9f14fff0b7dd87e10f17949.tar.gz
box64-07be405f48ab2571d9f14fff0b7dd87e10f17949.zip
Make sure Stack is aligned properly... (should help #1187 and ~1188)
Diffstat (limited to 'src/libtools/threads.c')
-rw-r--r--src/libtools/threads.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libtools/threads.c b/src/libtools/threads.c
index dad14fe1..d6a49a8a 100644
--- a/src/libtools/threads.c
+++ b/src/libtools/threads.c
@@ -652,7 +652,14 @@ int EXPORT my_pthread_once(x64emu_t* emu, int* once, void* cb)
 	#endif
 	if(old)
 		return 0;
+    // make some room and align R_RSP before doing the call (maybe it would be simpler to just use Callback functions)
+    Push64(emu, R_RBP); // push rbp
+    R_RBP = R_RSP;      // mov rbp, rsp
+    R_RSP -= 0x200;
+    R_RSP &= ~63LL;
 	DynaCall(emu, (uintptr_t)cb);  // using DynaCall, speedup wine 7.21 initialisation
+	R_RSP = R_RBP;          // mov rsp, rbp
+	R_RBP = Pop64(emu);     // pop rbp
 	return 0;
 }
 EXPORT int my___pthread_once(x64emu_t* emu, void* once, void* cb) __attribute__((alias("my_pthread_once")));