From 79e622a839f8002b066066164154e6c6e029ed41 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Fri, 17 May 2024 10:02:26 +0200 Subject: [PATCH] Setup stack nicely for pthread_once (might help wine) --- src/libtools/threads.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libtools/threads.c b/src/libtools/threads.c index 3c07c0231..07a16e659 100755 --- a/src/libtools/threads.c +++ b/src/libtools/threads.c @@ -454,7 +454,14 @@ int EXPORT my_pthread_once(x86emu_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) + Push32(emu, R_EBP); // push rbp + R_EBP = R_ESP; // mov rbp, rsp + R_ESP -= 0x200; + R_ESP &= ~63LL; DynaCall(emu, (uintptr_t)cb); // using DynaCall now, speedup wine 7.21 (proabbly other too) init + R_ESP = R_EBP; // mov rsp, rbp + R_EBP = Pop32(emu); // pop rbp return 0; } EXPORT int my___pthread_once(x86emu_t* emu, void* once, void* cb) __attribute__((alias("my_pthread_once")));