Commit 05235df0 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

concrt140: Avoid forwarding to msvcp120 by duplicating msvcp90/details.c.

parent 8e2df64c
...@@ -4,4 +4,5 @@ EXTRADLLFLAGS = -mno-cygwin ...@@ -4,4 +4,5 @@ EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \ C_SRCS = \
concrt140.c \ concrt140.c \
concurrency.c concurrency.c \
details.c
...@@ -23,18 +23,20 @@ ...@@ -23,18 +23,20 @@
#include "windef.h" #include "windef.h"
#include "winternl.h" #include "winternl.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "cxx.h" #include "details.h"
WINE_DEFAULT_DEBUG_CHANNEL(concrt); WINE_DEFAULT_DEBUG_CHANNEL(concrt);
CREATE_TYPE_INFO_VTABLE CREATE_TYPE_INFO_VTABLE
CREATE_EXCEPTION_OBJECT(exception)
static HMODULE msvcp140; static HMODULE msvcp140;
extern const vtable_ptr exception_vtable; extern const vtable_ptr exception_vtable;
int CDECL _callnewh(size_t size); int CDECL _callnewh(size_t size);
void (__cdecl *_Xbad_alloc)(void); void (__cdecl *_Xmem)(void);
void (__cdecl *_Xout_of_range)(const char*);
void* __cdecl operator_new(size_t size) void* __cdecl operator_new(size_t size)
{ {
...@@ -53,7 +55,7 @@ void* __cdecl operator_new(size_t size) ...@@ -53,7 +55,7 @@ void* __cdecl operator_new(size_t size)
} while (freed); } while (freed);
TRACE("(%Iu) out of memory\n", size); TRACE("(%Iu) out of memory\n", size);
_Xbad_alloc(); _Xmem();
return NULL; return NULL;
} }
...@@ -62,6 +64,47 @@ void __cdecl operator_delete(void *mem) ...@@ -62,6 +64,47 @@ void __cdecl operator_delete(void *mem)
free(mem); free(mem);
} }
typedef exception runtime_error;
extern const vtable_ptr runtime_error_vtable;
DEFINE_THISCALL_WRAPPER(runtime_error_copy_ctor,8)
runtime_error * __thiscall runtime_error_copy_ctor(runtime_error *this, const runtime_error *rhs)
{
return __exception_copy_ctor(this, rhs, &runtime_error_vtable);
}
typedef exception range_error;
extern const vtable_ptr range_error_vtable;
DEFINE_THISCALL_WRAPPER(range_error_copy_ctor,8)
range_error * __thiscall range_error_copy_ctor(range_error *this, const range_error *rhs)
{
return __exception_copy_ctor(this, rhs, &range_error_vtable);
}
__ASM_BLOCK_BEGIN(vtables)
__ASM_VTABLE(runtime_error,
VTABLE_ADD_FUNC(exception_vector_dtor)
VTABLE_ADD_FUNC(exception_what));
__ASM_VTABLE(range_error,
VTABLE_ADD_FUNC(exception_vector_dtor)
VTABLE_ADD_FUNC(exception_what));
__ASM_BLOCK_END
DEFINE_RTTI_DATA1(runtime_error, 0, &exception_rtti_base_descriptor, ".?AVruntime_error@std@@")
DEFINE_CXX_TYPE_INFO(runtime_error)
DEFINE_RTTI_DATA2(range_error, 0, &runtime_error_rtti_base_descriptor,
&exception_rtti_base_descriptor, ".?AVrange_error@std@@")
DEFINE_CXX_DATA2(range_error, &runtime_error_cxx_type_info,
&exception_cxx_type_info, exception_dtor)
void DECLSPEC_NORETURN throw_range_error(const char *str)
{
range_error e;
__exception_ctor(&e, str, &range_error_vtable);
_CxxThrowException(&e, &range_error_exception_type);
}
static BOOL init_cxx_funcs(void) static BOOL init_cxx_funcs(void)
{ {
msvcp140 = LoadLibraryA("msvcp140.dll"); msvcp140 = LoadLibraryA("msvcp140.dll");
...@@ -71,10 +114,11 @@ static BOOL init_cxx_funcs(void) ...@@ -71,10 +114,11 @@ static BOOL init_cxx_funcs(void)
return FALSE; return FALSE;
} }
_Xbad_alloc = (void*)GetProcAddress(msvcp140, "?_Xbad_alloc@std@@YAXXZ"); _Xmem = (void*)GetProcAddress(msvcp140, "?_Xbad_alloc@std@@YAXXZ");
if (!_Xbad_alloc) _Xout_of_range = (void*)GetProcAddress(msvcp140, sizeof(void*) > sizeof(int) ?
"?_Xout_of_range@std@@YAXPEBD@Z" : "?_Xout_of_range@std@@YAXPBD@Z");
if (!_Xmem || !_Xout_of_range)
{ {
FIXME("Failed to get address of ?_Xbad_alloc@std@@YAXXZ\n");
FreeLibrary(msvcp140); FreeLibrary(msvcp140);
return FALSE; return FALSE;
} }
...@@ -89,9 +133,17 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) ...@@ -89,9 +133,17 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
if (!init_cxx_funcs()) return FALSE; if (!init_cxx_funcs()) return FALSE;
#ifdef __x86_64__ #ifdef __x86_64__
init_exception_rtti((char*)inst);
init_range_error_rtti((char*)inst);
init_runtime_error_rtti((char*)inst);
init_type_info_rtti((char*)inst); init_type_info_rtti((char*)inst);
init_exception_cxx_type_info((char*)inst);
init_runtime_error_cxx_type_info((char*)inst);
init_range_error_cxx((char*)inst);
#endif #endif
msvcrt_init_concurrency(inst); msvcrt_init_concurrency(inst);
init_concurrency_details(inst);
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
if (reserved) break; if (reserved) break;
......
/*
* Copyright 2021 Piotr Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdbool.h>
#include <stdlib.h>
#include "windef.h"
#include "winternl.h"
#include "cxx.h"
void* __cdecl operator_new(size_t);
void __cdecl operator_delete(void*);
bool __cdecl Context_IsCurrentTaskCollectionCanceling(void);
void init_concurrency_details(void*);
void WINAPI DECLSPEC_NORETURN _CxxThrowException(void*,const cxx_exception_type*);
extern void (__cdecl *_Xmem)(void);
extern void (__cdecl *_Xout_of_range)(const char*);
void DECLSPEC_NORETURN throw_range_error(const char*);
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/* Keep in sync with concrt140/detail.c */
#include <stdarg.h> #include <stdarg.h>
#include "msvcp90.h" #include "msvcp90.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment