Piotr Caban : msvcp70: Don't forward bad_alloc implementation to msvcrt.
Alexandre Julliard
julliard at winehq.org
Fri Feb 7 10:13:43 CST 2014
Module: wine
Branch: master
Commit: 2b1e2e64da244969748148fe31f66569cd307316
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2b1e2e64da244969748148fe31f66569cd307316
Author: Piotr Caban <piotr at codeweavers.com>
Date: Fri Feb 7 10:35:10 2014 +0100
msvcp70: Don't forward bad_alloc implementation to msvcrt.
---
dlls/msvcp70/msvcp70.spec | 20 ++++++------
dlls/msvcp90/exception.c | 75 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 85 insertions(+), 10 deletions(-)
diff --git a/dlls/msvcp70/msvcp70.spec b/dlls/msvcp70/msvcp70.spec
index fbff36a..88c6328 100644
--- a/dlls/msvcp70/msvcp70.spec
+++ b/dlls/msvcp70/msvcp70.spec
@@ -446,10 +446,10 @@
@ stub -arch=win64 ??0__non_rtti_object at std@@QEAA at AEBV01@@Z
@ stub -arch=win32 ??0__non_rtti_object at std@@QAE at PBD@Z
@ stub -arch=win64 ??0__non_rtti_object at std@@QEAA at PEBD@Z
-@ thiscall -arch=i386 ??0bad_cast at std@@QAE at ABV01@@Z(ptr ptr) msvcrt.??0bad_cast@@QAE at ABV0@@Z
-@ cdecl -arch=win64 ??0bad_cast at std@@QEAA at AEBV01@@Z(ptr ptr) msvcrt.??0bad_cast@@QEAA at AEBV0@@Z
-@ thiscall -arch=i386 ??0bad_cast at std@@QAE at PBD@Z(ptr str) msvcrt.??0bad_cast@@QAE at PBD@Z
-@ cdecl -arch=win64 ??0bad_cast at std@@QEAA at PEBD@Z(ptr str) msvcrt.??0bad_cast@@QEAA at PEBD@Z
+@ thiscall -arch=i386 ??0bad_cast at std@@QAE at ABV01@@Z(ptr ptr) MSVCP_bad_cast_copy_ctor
+@ cdecl -arch=win64 ??0bad_cast at std@@QEAA at AEBV01@@Z(ptr ptr) MSVCP_bad_cast_copy_ctor
+@ thiscall -arch=i386 ??0bad_cast at std@@QAE at PBD@Z(ptr str) MSVCP_bad_cast_ctor
+@ cdecl -arch=win64 ??0bad_cast at std@@QEAA at PEBD@Z(ptr str) MSVCP_bad_cast_ctor
@ stub -arch=win32 ??0bad_typeid at std@@QAE at ABV01@@Z
@ stub -arch=win64 ??0bad_typeid at std@@QEAA at AEBV01@@Z
@ stub -arch=win32 ??0bad_typeid at std@@QAE at PBD@Z
@@ -672,8 +672,8 @@
@ cdecl -arch=win64 ??1_Winit at std@@QEAA at XZ(ptr) _Winit_dtor
@ stub -arch=win32 ??1__non_rtti_object at std@@UAE at XZ
@ stub -arch=win64 ??1__non_rtti_object at std@@UEAA at XZ
-@ thiscall -arch=i386 ??1bad_cast at std@@UAE at XZ(ptr) msvcrt.??1bad_cast@@UAE at XZ
-@ cdecl -arch=win64 ??1bad_cast at std@@UEAA at XZ(ptr) msvcrt.??1bad_cast@@UEAA at XZ
+@ thiscall -arch=i386 ??1bad_cast at std@@UAE at XZ(ptr) MSVCP_bad_cast_dtor
+@ cdecl -arch=win64 ??1bad_cast at std@@UEAA at XZ(ptr) MSVCP_bad_cast_dtor
@ stub -arch=win32 ??1bad_typeid at std@@UAE at XZ
@ stub -arch=win64 ??1bad_typeid at std@@UEAA at XZ
@ thiscall -arch=i386 ??1codecvt_base at std@@UAE at XZ(ptr) codecvt_base_dtor
@@ -812,8 +812,8 @@
@ cdecl -arch=win64 ??4_Winit at std@@QEAAAEAV01 at AEBV01@@Z(ptr ptr) _Winit_op_assign
@ stub -arch=win32 ??4__non_rtti_object at std@@QAEAAV01 at ABV01@@Z
@ stub -arch=win64 ??4__non_rtti_object at std@@QEAAAEAV01 at AEBV01@@Z
-@ thiscall -arch=i386 ??4bad_cast at std@@QAEAAV01 at ABV01@@Z(ptr ptr) msvcrt.??4bad_cast@@QAEAAV0 at ABV0@@Z
-@ cdecl -arch=win64 ??4bad_cast at std@@QEAAAEAV01 at AEBV01@@Z(ptr ptr) msvcrt.??4bad_cast@@QEAAAEAV0 at AEBV0@@Z
+@ thiscall -arch=i386 ??4bad_cast at std@@QAEAAV01 at ABV01@@Z(ptr ptr) MSVCP_bad_cast_opequals
+@ cdecl -arch=win64 ??4bad_cast at std@@QEAAAEAV01 at AEBV01@@Z(ptr ptr) MSVCP_bad_cast_opequals
@ stub -arch=win32 ??4bad_typeid at std@@QAEAAV01 at ABV01@@Z
@ stub -arch=win64 ??4bad_typeid at std@@QEAAAEAV01 at AEBV01@@Z
@ thiscall -arch=win32 ??4ios_base at std@@QAEAAV01 at ABV01@@Z(ptr ptr) ios_base_assign
@@ -1726,8 +1726,8 @@
@ cdecl -arch=win64 ??_F_Locinfo at std@@QEAAXXZ(ptr) _Locinfo_ctor
@ thiscall -arch=i386 ??_F_Timevec at std@@QAEXXZ(ptr) _Timevec_ctor
@ cdecl -arch=win64 ??_F_Timevec at std@@QEAAXXZ(ptr) _Timevec_ctor
-@ thiscall -arch=i386 ??_Fbad_cast at std@@QAEXXZ(ptr) msvcrt.??_Fbad_cast@@QAEXXZ
-@ cdecl -arch=win64 ??_Fbad_cast at std@@QEAAXXZ(ptr) msvcrt.??_Fbad_cast@@QEAAXXZ
+@ thiscall -arch=i386 ??_Fbad_cast at std@@QAEXXZ(ptr) MSVCP_bad_cast_default_ctor
+@ cdecl -arch=win64 ??_Fbad_cast at std@@QEAAXXZ(ptr) MSVCP_bad_cast_default_ctor
@ stub -arch=win32 ??_Fbad_typeid at std@@QAEXXZ
@ stub -arch=win64 ??_Fbad_typeid at std@@QEAAXXZ
@ thiscall -arch=i386 ??_Fcodecvt_base at std@@QAEXXZ(ptr) codecvt_base_ctor
diff --git a/dlls/msvcp90/exception.c b/dlls/msvcp90/exception.c
index dfd35d9..da3a4bf 100644
--- a/dlls/msvcp90/exception.c
+++ b/dlls/msvcp90/exception.c
@@ -41,6 +41,7 @@ extern const vtable_ptr MSVCP_out_of_range_vtable;
extern const vtable_ptr MSVCP_invalid_argument_vtable;
extern const vtable_ptr MSVCP_runtime_error_vtable;
extern const vtable_ptr MSVCP_failure_vtable;
+extern const vtable_ptr MSVCP_bad_cast_vtable;
static void MSVCP_type_info_dtor(type_info * _this)
{
@@ -447,6 +448,75 @@ const char* __thiscall MSVCP_failure_what(failure *this)
DEFINE_RTTI_DATA2(failure, 0, &runtime_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVfailure at std@@")
DEFINE_CXX_DATA2(failure, &runtime_error_cxx_type_info, &exception_cxx_type_info, MSVCP_runtime_error_dtor)
+/* bad_cast class data */
+typedef exception bad_cast;
+
+DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_ctor, 8)
+bad_cast* __thiscall MSVCP_bad_cast_ctor(bad_cast *this, const char *name)
+{
+ TRACE("%p %s\n", this, name);
+ MSVCP_exception_ctor(this, &name);
+ this->vtable = &MSVCP_bad_cast_vtable;
+ return this;
+}
+
+DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_default_ctor,4)
+bad_cast* __thiscall MSVCP_bad_cast_default_ctor(bad_cast *this)
+{
+ return MSVCP_bad_cast_ctor(this, "bad cast");
+}
+
+DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_copy_ctor, 8)
+bad_cast* __thiscall MSVCP_bad_cast_copy_ctor(bad_cast *this, const bad_cast *rhs)
+{
+ TRACE("%p %p\n", this, rhs);
+ MSVCP_exception_copy_ctor(this, rhs);
+ this->vtable = &MSVCP_bad_cast_vtable;
+ return this;
+}
+
+DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_dtor, 4)
+void __thiscall MSVCP_bad_cast_dtor(bad_cast *this)
+{
+ TRACE("%p\n", this);
+ MSVCP_exception_dtor(this);
+}
+
+DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_vector_dtor, 8)
+void * __thiscall MSVCP_bad_cast_vector_dtor(bad_cast *this, unsigned int flags)
+{
+ TRACE("%p %x\n", this, flags);
+ if(flags & 2) {
+ /* we have an array, with the number of elements stored before the first object */
+ INT_PTR i, *ptr = (INT_PTR *)this-1;
+
+ for(i=*ptr-1; i>=0; i--)
+ MSVCP_bad_cast_dtor(this+i);
+ MSVCRT_operator_delete(ptr);
+ } else {
+ MSVCP_bad_cast_dtor(this);
+ if(flags & 1)
+ MSVCRT_operator_delete(this);
+ }
+
+ return this;
+}
+
+DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_opequals, 8)
+bad_cast* __thiscall MSVCP_bad_cast_opequals(bad_cast *this, const bad_cast *rhs)
+{
+ TRACE("(%p %p)\n", this, rhs);
+
+ if(this != rhs) {
+ MSVCP_exception_dtor(this);
+ MSVCP_exception_copy_ctor(this, rhs);
+ }
+ return this;
+}
+
+DEFINE_RTTI_DATA1(bad_cast, 0, &exception_rtti_base_descriptor, ".?AVbad_cast at std@@")
+DEFINE_CXX_DATA1(bad_cast, &exception_cxx_type_info, MSVCP_bad_cast_dtor)
+
/* ?_Nomemory at std@@YAXXZ */
void __cdecl _Nomemory(void)
{
@@ -528,6 +598,9 @@ void __asm_dummy_vtables(void) {
__ASM_VTABLE(failure,
VTABLE_ADD_FUNC(MSVCP_failure_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_failure_what));
+ __ASM_VTABLE(bad_cast,
+ VTABLE_ADD_FUNC(MSVCP_bad_cast_vector_dtor)
+ VTABLE_ADD_FUNC(MSVCP_what_exception));
#ifndef __GNUC__
}
#endif
@@ -595,6 +668,7 @@ void init_exception(void *base)
init_invalid_argument_rtti(base);
init_runtime_error_rtti(base);
init_failure_rtti(base);
+ init_bad_cast_rtti(base);
init_exception_cxx(base);
init_bad_alloc_cxx(base);
@@ -604,5 +678,6 @@ void init_exception(void *base)
init_invalid_argument_cxx(base);
init_runtime_error_cxx(base);
init_failure_cxx(base);
+ init_bad_cast_cxx(base);
#endif
}
More information about the wine-cvs
mailing list