[PATCH v2 0/1] MR4864: msvcp: Use proper operator_new and operator_delete types for msvcirt.
-- v2: msvcirt: Use proper operator_new and operator_delete types for msvcirt. https://gitlab.winehq.org/wine/wine/-/merge_requests/4864
From: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> msvcirt's PARENTSRC imports exception.c from msvcp90, but it uses a function pointer for these functions, resulting in a type mismatch. Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c index 8d83fca..54d7b54 100644 --- a/dlls/msvcirt/msvcirt.c +++ b/dlls/msvcirt/msvcirt.c @@ -38,9 +38,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcirt); #define RESERVE_SIZE 512 #define STATEBUF_SIZE 8 -void* (__cdecl *operator_new)(SIZE_T); -void (__cdecl *operator_delete)(void*); - /* ?sh_none(a)filebuf@@2HB */ const int filebuf_sh_none = 0x800; /* ?sh_read(a)filebuf@@2HB */ @@ -5132,19 +5129,32 @@ void __cdecl _mtunlock(CRITICAL_SECTION *crit) LeaveCriticalSection(crit); } +static void* (__cdecl *MSVCRT_operator_new)(SIZE_T); +static void (__cdecl *MSVCRT_operator_delete)(void*); + +void* __cdecl operator_new(SIZE_T size) +{ + return MSVCRT_operator_new(size); +} + +void __cdecl operator_delete(void *mem) +{ + MSVCRT_operator_delete(mem); +} + static void init_cxx_funcs(void) { HMODULE hmod = GetModuleHandleA("msvcrt.dll"); if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */ { - operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPEAX_K@Z"); - operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPEAX@Z"); + MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPEAX_K@Z"); + MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPEAX@Z"); } else { - operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPAXI@Z"); - operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPAX@Z"); + MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPAXI@Z"); + MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPAX@Z"); } } diff --git a/dlls/msvcirt/msvcirt.h b/dlls/msvcirt/msvcirt.h index 5b59b78..875a4fd 100644 --- a/dlls/msvcirt/msvcirt.h +++ b/dlls/msvcirt/msvcirt.h @@ -68,7 +68,7 @@ typedef enum { FLAGS_stdio = 0x4000 } ios_flags; -extern void* (__cdecl *MSVCRT_operator_new)(SIZE_T); -extern void (__cdecl *MSVCRT_operator_delete)(void*); +void* __cdecl operator_new(SIZE_T); +void __cdecl operator_delete(void*); void init_exception(void*); -- 2.43.0 --- dlls/msvcirt/msvcirt.c | 24 +++++++++++++++++------- dlls/msvcirt/msvcirt.h | 4 ++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c index 8d83fca7c94..0fcdc52c203 100644 --- a/dlls/msvcirt/msvcirt.c +++ b/dlls/msvcirt/msvcirt.c @@ -38,9 +38,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcirt); #define RESERVE_SIZE 512 #define STATEBUF_SIZE 8 -void* (__cdecl *operator_new)(SIZE_T); -void (__cdecl *operator_delete)(void*); - /* ?sh_none(a)filebuf@@2HB */ const int filebuf_sh_none = 0x800; /* ?sh_read(a)filebuf@@2HB */ @@ -5132,19 +5129,32 @@ void __cdecl _mtunlock(CRITICAL_SECTION *crit) LeaveCriticalSection(crit); } +static void* (__cdecl *MSVCRT_operator_new)(SIZE_T); +static void (__cdecl *MSVCRT_operator_delete)(void*); + +void* __cdecl operator_new(SIZE_T size) +{ + return MSVCRT_operator_new(size); +} + +void __cdecl operator_delete(void *mem) +{ + MSVCRT_operator_delete(mem); +} + static void init_cxx_funcs(void) { HMODULE hmod = GetModuleHandleA("msvcrt.dll"); if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */ { - operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPEAX_K@Z"); - operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPEAX@Z"); + MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPEAX_K@Z"); + MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPEAX@Z"); } else { - operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPAXI@Z"); - operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPAX@Z"); + MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPAXI@Z"); + MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPAX@Z"); } } diff --git a/dlls/msvcirt/msvcirt.h b/dlls/msvcirt/msvcirt.h index 5b59b7862a3..ccbc7027146 100644 --- a/dlls/msvcirt/msvcirt.h +++ b/dlls/msvcirt/msvcirt.h @@ -68,7 +68,7 @@ typedef enum { FLAGS_stdio = 0x4000 } ios_flags; -extern void* (__cdecl *MSVCRT_operator_new)(SIZE_T); -extern void (__cdecl *MSVCRT_operator_delete)(void*); +void* __cdecl operator_new(SIZE_T); +void __cdecl operator_delete(void*); void init_exception(void*); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4864
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=142047 Your paranoid android. === debian11 (build log) === error: corrupt patch at line 50 Task: Patch failed to apply === debian11b (build log) === error: corrupt patch at line 50 Task: Patch failed to apply
On Thu Jan 18 18:17:16 2024 +0000, Piotr Caban wrote:
Take a look on `operator_new` and `operator_delete` functions in dlls/msvcp90/msvcp_main.c. It's a simple wrapper that calls `MSVCRT_operator_new` function. Thanks, something seems to have been messed up, let me retry pushing.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/4864#note_57990
participants (2)
-
Gabriel Ivăncescu -
Marvin