msvcirt: Share exceptions implementation with msvcp (try 2)

Iván Matellanes matellanesivan at gmail.com
Tue May 26 06:08:39 CDT 2015


Try 2: removed an unnecessary ifdef

---
 dlls/msvcirt/Makefile.in  |   3 ++
 dlls/msvcirt/msvcirt.c    |  40 ++++++++--------
 dlls/msvcirt/msvcirt.h    |  25 ++++++++++
 dlls/msvcirt/msvcirt.spec |  52 ++++++++++-----------
 dlls/msvcp90/exception.c  | 115 ++++++++++++++++++++++++++++++++++++++++------
 5 files changed, 174 insertions(+), 61 deletions(-)
 create mode 100644 dlls/msvcirt/msvcirt.h

diff --git a/dlls/msvcirt/Makefile.in b/dlls/msvcirt/Makefile.in
index 21a9801..acaf495 100644
--- a/dlls/msvcirt/Makefile.in
+++ b/dlls/msvcirt/Makefile.in
@@ -1,5 +1,8 @@
 MODULE    = msvcirt.dll
 IMPORTS   = msvcrt
+EXTRADEFS = -D_MSVCIRT
+PARENTSRC = ../msvcp90
 
 C_SRCS = \
+	exception.c \
 	msvcirt.c
diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c
index a561412..e73f93e 100644
--- a/dlls/msvcirt/msvcirt.c
+++ b/dlls/msvcirt/msvcirt.c
@@ -20,6 +20,7 @@
 
 #include <stdarg.h>
 
+#include "msvcirt.h"
 #include "windef.h"
 #include "winbase.h"
 #include "wine/debug.h"
@@ -38,27 +39,6 @@ typedef struct {
     LPVOID VTable;
 } class_strstreambuf;
 
-#ifdef __i386__  /* thiscall functions are i386-specific */
-
-#define THISCALL(func) __thiscall_ ## func
-#define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func)
-#define __thiscall __stdcall
-#define DEFINE_THISCALL_WRAPPER(func,args) \
-    extern void THISCALL(func)(void); \
-    __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
-                      "popl %eax\n\t" \
-                      "pushl %ecx\n\t" \
-                      "pushl %eax\n\t" \
-                      "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
-#else /* __i386__ */
-
-#define THISCALL(func) func
-#define THISCALL_NAME(func) __ASM_NAME(#func)
-#define __thiscall __cdecl
-#define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
-
-#endif /* __i386__ */
-
 /******************************************************************
  *		 ??1ios@@UAE at XZ (MSVCRTI.@)
  *        class ios & __thiscall ios::-ios<<(void)
@@ -156,6 +136,22 @@ char * __thiscall MSVCIRT_str_sl_void(class_strstreambuf * _this)
    return 0;
 }
 
+void (__cdecl *MSVCRT_operator_delete)(void*);
+
+static void init_cxx_funcs(void)
+{
+    HMODULE hmod = GetModuleHandleA("msvcrt.dll");
+
+    if (sizeof(void *) > sizeof(int))  /* 64-bit has different names */
+    {
+        MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3 at YAXPEAX@Z");
+    }
+    else
+    {
+        MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3 at YAXPAX@Z");
+    }
+}
+
 BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
 {
    switch (reason)
@@ -163,6 +159,8 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
    case DLL_WINE_PREATTACH:
        return FALSE;  /* prefer native version */
    case DLL_PROCESS_ATTACH:
+       init_cxx_funcs();
+       init_exception(inst);
        DisableThreadLibraryCalls( inst );
        break;
    }
diff --git a/dlls/msvcirt/msvcirt.h b/dlls/msvcirt/msvcirt.h
new file mode 100644
index 0000000..4301528
--- /dev/null
+++ b/dlls/msvcirt/msvcirt.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Iván Matellanes
+ *
+ * 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 "stdlib.h"
+#include "windef.h"
+#include "cxx.h"
+
+extern void (__cdecl *MSVCRT_operator_delete)(void*);
+
+void init_exception(void*);
diff --git a/dlls/msvcirt/msvcirt.spec b/dlls/msvcirt/msvcirt.spec
index baafadb..3399b5d 100644
--- a/dlls/msvcirt/msvcirt.spec
+++ b/dlls/msvcirt/msvcirt.spec
@@ -2,12 +2,12 @@
 @ stub -arch=win64 ??0Iostream_init@@QEAA at AEAVios@@H at Z
 @ stub -arch=win32 ??0Iostream_init@@QAE at XZ  # __thiscall Iostream_init::Iostream_init(void)
 @ stub -arch=win64 ??0Iostream_init@@QEAA at XZ
-@ thiscall -arch=i386 ??0exception@@QAE at ABQBD@Z(ptr ptr) msvcrt.??0exception@@QAE at ABQBD@Z
-@ cdecl -arch=win64 ??0exception@@QEAA at AEBQEBD@Z(ptr ptr) msvcrt.??0exception@@QEAA at AEBQEBD@Z
-@ thiscall -arch=i386 ??0exception@@QAE at ABV0@@Z(ptr ptr) msvcrt.??0exception@@QAE at ABV0@@Z
-@ cdecl -arch=win64 ??0exception@@QEAA at AEBV0@@Z(ptr ptr) msvcrt.??0exception@@QEAA at AEBV0@@Z
-@ thiscall -arch=i386 ??0exception@@QAE at XZ(ptr) msvcrt.??0exception@@QAE at XZ
-@ cdecl -arch=win64 ??0exception@@QEAA at XZ(ptr) msvcrt.??0exception@@QEAA at XZ
+@ thiscall -arch=i386 ??0exception@@QAE at ABQBD@Z(ptr ptr) MSVCP_exception_ctor
+@ cdecl -arch=win64 ??0exception@@QEAA at AEBQEBD@Z(ptr ptr) MSVCP_exception_ctor
+@ thiscall -arch=i386 ??0exception@@QAE at ABV0@@Z(ptr ptr) MSVCP_exception_copy_ctor
+@ cdecl -arch=win64 ??0exception@@QEAA at AEBV0@@Z(ptr ptr) MSVCP_exception_copy_ctor
+@ thiscall -arch=i386 ??0exception@@QAE at XZ(ptr) MSVCP_exception_default_ctor
+@ cdecl -arch=win64 ??0exception@@QEAA at XZ(ptr) MSVCP_exception_default_ctor
 @ stub -arch=win32 ??0filebuf@@QAE at ABV0@@Z  # __thiscall filebuf::filebuf(class filebuf const &)
 @ stub -arch=win64 ??0filebuf@@QEAA at AEBV0@@Z
 @ stub -arch=win32 ??0filebuf@@QAE at H@Z  # __thiscall filebuf::filebuf(int)
@@ -66,10 +66,10 @@
 @ stub -arch=win64 ??0istrstream@@QEAA at PEAD@Z
 @ stub -arch=win32 ??0istrstream@@QAE at PADH@Z  # __thiscall istrstream::istrstream(char *,int)
 @ stub -arch=win64 ??0istrstream@@QEAA at PEADH@Z
-@ stub -arch=win32 ??0logic_error@@QAE at ABQBD@Z  # __thiscall logic_error::logic_error(char const * const &)
-@ stub -arch=win64 ??0logic_error@@QEAA at AEBQEBD@Z
-@ stub -arch=win32 ??0logic_error@@QAE at ABV0@@Z  # __thiscall logic_error::logic_error(class logic_error const &)
-@ stub -arch=win64 ??0logic_error@@QEAA at AEBV0@@Z
+@ thiscall -arch=win32 ??0logic_error@@QAE at ABQBD@Z(ptr ptr) MSVCP_logic_error_ctor
+@ cdecl -arch=win64 ??0logic_error@@QEAA at AEBQEBD@Z(ptr ptr) MSVCP_logic_error_ctor
+@ thiscall -arch=win32 ??0logic_error@@QAE at ABV0@@Z(ptr ptr) MSVCP_logic_error_copy_ctor
+@ cdecl -arch=win64 ??0logic_error@@QEAA at AEBV0@@Z(ptr ptr) MSVCP_logic_error_copy_ctor
 @ stub -arch=win32 ??0ofstream@@QAE at ABV0@@Z  # __thiscall ofstream::ofstream(class ofstream const &)
 @ stub -arch=win64 ??0ofstream@@QEAA at AEBV0@@Z
 @ stub -arch=win32 ??0ofstream@@QAE at H@Z  # __thiscall ofstream::ofstream(int)
@@ -132,8 +132,8 @@
 @ stub -arch=win64 ??0strstreambuf@@QEAA at XZ
 @ stub -arch=win32 ??1Iostream_init@@QAE at XZ  # __thiscall Iostream_init::~Iostream_init(void)
 @ stub -arch=win64 ??1Iostream_init@@QEAA at XZ
-@ thiscall -arch=i386 ??1exception@@UAE at XZ(ptr) msvcrt.??1exception@@UAE at XZ
-@ cdecl -arch=win64 ??1exception@@UEAA at XZ(ptr) msvcrt.??1exception@@UEAA at XZ
+@ thiscall -arch=i386 ??1exception@@UAE at XZ(ptr) MSVCP_exception_dtor
+@ cdecl -arch=win64 ??1exception@@UEAA at XZ(ptr) MSVCP_exception_dtor
 @ stub -arch=win32 ??1filebuf@@UAE at XZ  # virtual __thiscall filebuf::~filebuf(void)
 @ stub -arch=win64 ??1filebuf@@UEAA at XZ
 @ stub -arch=win32 ??1fstream@@UAE at XZ  # virtual __thiscall fstream::~fstream(void)
@@ -150,8 +150,8 @@
 @ stub -arch=win64 ??1istream_withassign@@UEAA at XZ
 @ stub -arch=win32 ??1istrstream@@UAE at XZ  # virtual __thiscall istrstream::~istrstream(void)
 @ stub -arch=win64 ??1istrstream@@UEAA at XZ
-@ stub -arch=win32 ??1logic_error@@UAE at XZ  # virtual __thiscall logic_error::~logic_error(void)
-@ stub -arch=win64 ??1logic_error@@UEAA at XZ
+@ thiscall -arch=win32 ??1logic_error@@UAE at XZ(ptr) MSVCP_logic_error_dtor
+@ cdecl -arch=win64 ??1logic_error@@UEAA at XZ(ptr) MSVCP_logic_error_dtor
 @ stub -arch=win32 ??1ofstream@@UAE at XZ  # virtual __thiscall ofstream::~ofstream(void)
 @ stub -arch=win64 ??1ofstream@@UEAA at XZ
 @ stub -arch=win32 ??1ostream@@UAE at XZ  # virtual __thiscall ostream::~ostream(void)
@@ -172,8 +172,8 @@
 @ stub -arch=win64 ??1strstreambuf@@UEAA at XZ
 @ stub -arch=win32 ??4Iostream_init@@QAEAAV0 at ABV0@@Z  # class Iostream_init & __thiscall Iostream_init::operator=(class Iostream_init const &)
 @ stub -arch=win64 ??4Iostream_init@@QEAAAEAV0 at AEBV0@@Z
-@ thiscall -arch=i386 ??4exception@@QAEAAV0 at ABV0@@Z(ptr ptr) msvcrt.??4exception@@QAEAAV0 at ABV0@@Z
-@ cdecl -arch=win64 ??4exception@@QEAAAEAV0 at AEBV0@@Z(ptr ptr) msvcrt.??4exception@@QEAAAEAV0 at AEBV0@@Z
+@ thiscall -arch=i386 ??4exception@@QAEAAV0 at ABV0@@Z(ptr ptr) MSVCP_exception_assign
+@ cdecl -arch=win64 ??4exception@@QEAAAEAV0 at AEBV0@@Z(ptr ptr) MSVCP_exception_assign
 @ stub -arch=win32 ??4filebuf@@QAEAAV0 at ABV0@@Z  # class filebuf & __thiscall filebuf::operator=(class filebuf const &)
 @ stub -arch=win64 ??4filebuf@@QEAAAEAV0 at AEBV0@@Z
 @ stub -arch=win32 ??4fstream@@QAEAAV0 at AAV0@@Z  # class fstream & __thiscall fstream::operator=(class fstream &)
@@ -198,8 +198,8 @@
 @ stub -arch=win64 ??4istream_withassign@@QEAAAEAVistream@@PEAVstreambuf@@@Z
 @ stub -arch=win32 ??4istrstream@@QAEAAV0 at ABV0@@Z  # class istrstream & __thiscall istrstream::operator=(class istrstream const &)
 @ stub -arch=win64 ??4istrstream@@QEAAAEAV0 at AEBV0@@Z
-@ stub -arch=win32 ??4logic_error@@QAEAAV0 at ABV0@@Z  # class logic_error & __thiscall logic_error::operator=(class logic_error const &)
-@ stub -arch=win64 ??4logic_error@@QEAAAEAV0 at AEBV0@@Z
+@ thiscall -arch=win32 ??4logic_error@@QAEAAV0 at ABV0@@Z(ptr ptr) MSVCP_logic_error_assign
+@ cdecl -arch=win64 ??4logic_error@@QEAAAEAV0 at AEBV0@@Z(ptr ptr) MSVCP_logic_error_assign
 @ stub -arch=win32 ??4ofstream@@QAEAAV0 at ABV0@@Z  # class ofstream & __thiscall ofstream::operator=(class ofstream const &)
 @ stub -arch=win64 ??4ofstream@@QEAAAEAV0 at AEBV0@@Z
 @ stub -arch=win32 ??4ostream@@IAEAAV0 at ABV0@@Z  # class ostream & __thiscall ostream::operator=(class ostream const &)
@@ -302,7 +302,7 @@
 @ stub -arch=win64 ??7ios@@QEBAHXZ
 @ stub -arch=win32 ??Bios@@QBEPAXXZ  # __thiscall ios::operator void *(void)const 
 @ stub -arch=win64 ??Bios@@QEBAPEAXXZ
-@ extern ??_7exception@@6B@ msvcrt.??_7exception@@6B@
+@ extern ??_7exception@@6B@ MSVCP_exception_vtable
 # @ extern ??_7filebuf@@6B@  # const filebuf::`vftable'
 # @ extern ??_7fstream@@6B@  # const fstream::`vftable'
 # @ extern ??_7ifstream@@6B@  # const ifstream::`vftable'
@@ -311,7 +311,7 @@
 # @ extern ??_7istream@@6B@  # const istream::`vftable'
 # @ extern ??_7istream_withassign@@6B@  # const istream_withassign::`vftable'
 # @ extern ??_7istrstream@@6B@  # const istrstream::`vftable'
-# @ extern ??_7logic_error@@6B@  # const logic_error::`vftable'
+@ extern ??_7logic_error@@6B@ MSVCP_logic_error_vtable
 # @ extern ??_7ofstream@@6B@  # const ofstream::`vftable'
 # @ extern ??_7ostream@@6B@  # const ostream::`vftable'
 # @ extern ??_7ostream_withassign@@6B@  # const ostream_withassign::`vftable'
@@ -361,7 +361,7 @@
 @ stub -arch=win64 ??_Dstdiostream@@QEAAXXZ
 @ stub -arch=win32 ??_Dstrstream@@QAEXXZ  # void __thiscall strstream::`vbase destructor'(void)
 @ stub -arch=win64 ??_Dstrstream@@QEAAXXZ
-@ thiscall -arch=win32 ??_Eexception@@UAEPAXI at Z(ptr long) msvcrt.??_Eexception@@UAEPAXI at Z  # virtual void * __thiscall exception::`vector deleting destructor'(unsigned int)
+@ thiscall -arch=win32 ??_Eexception@@UAEPAXI at Z(ptr long) MSVCP_exception_vector_dtor
 @ stub -arch=win32 ??_Efilebuf@@UAEPAXI at Z  # virtual void * __thiscall filebuf::`vector deleting destructor'(unsigned int)
 @ stub -arch=win32 ??_Efstream@@UAEPAXI at Z  # virtual void * __thiscall fstream::`vector deleting destructor'(unsigned int)
 @ stub -arch=win32 ??_Eifstream@@UAEPAXI at Z  # virtual void * __thiscall ifstream::`vector deleting destructor'(unsigned int)
@@ -370,7 +370,7 @@
 @ stub -arch=win32 ??_Eistream@@UAEPAXI at Z  # virtual void * __thiscall istream::`vector deleting destructor'(unsigned int)
 @ stub -arch=win32 ??_Eistream_withassign@@UAEPAXI at Z  # virtual void * __thiscall istream_withassign::`vector deleting destructor'(unsigned int)
 @ stub -arch=win32 ??_Eistrstream@@UAEPAXI at Z  # virtual void * __thiscall istrstream::`vector deleting destructor'(unsigned int)
-@ stub -arch=win32 ??_Elogic_error@@UAEPAXI at Z  # virtual void * __thiscall logic_error::`vector deleting destructor'(unsigned int)
+@ thiscall -arch=win32 ??_Elogic_error@@UAEPAXI at Z(ptr long) MSVCP_logic_error_vector_dtor
 @ stub -arch=win32 ??_Eofstream@@UAEPAXI at Z  # virtual void * __thiscall ofstream::`vector deleting destructor'(unsigned int)
 @ stub -arch=win32 ??_Eostream@@UAEPAXI at Z  # virtual void * __thiscall ostream::`vector deleting destructor'(unsigned int)
 @ stub -arch=win32 ??_Eostream_withassign@@UAEPAXI at Z  # virtual void * __thiscall ostream_withassign::`vector deleting destructor'(unsigned int)
@@ -380,7 +380,7 @@
 @ stub -arch=win32 ??_Estreambuf@@UAEPAXI at Z  # virtual void * __thiscall streambuf::`vector deleting destructor'(unsigned int)
 @ stub -arch=win32 ??_Estrstream@@UAEPAXI at Z  # virtual void * __thiscall strstream::`vector deleting destructor'(unsigned int)
 @ stub -arch=win32 ??_Estrstreambuf@@UAEPAXI at Z  # virtual void * __thiscall strstreambuf::`vector deleting destructor'(unsigned int)
-@ thiscall -arch=win32 ??_Gexception@@UAEPAXI at Z(ptr long) msvcrt.??_Gexception@@UAEPAXI at Z  # virtual void * __thiscall exception::`scalar deleting destructor'(unsigned int)
+@ thiscall -arch=win32 ??_Gexception@@UAEPAXI at Z(ptr long) MSVCP_exception_scalar_dtor
 @ stub -arch=win32 ??_Gfilebuf@@UAEPAXI at Z  # virtual void * __thiscall filebuf::`scalar deleting destructor'(unsigned int)
 @ stub -arch=win32 ??_Gfstream@@UAEPAXI at Z  # virtual void * __thiscall fstream::`scalar deleting destructor'(unsigned int)
 @ stub -arch=win32 ??_Gifstream@@UAEPAXI at Z  # virtual void * __thiscall ifstream::`scalar deleting destructor'(unsigned int)
@@ -389,7 +389,7 @@
 @ stub -arch=win32 ??_Gistream@@UAEPAXI at Z  # virtual void * __thiscall istream::`scalar deleting destructor'(unsigned int)
 @ stub -arch=win32 ??_Gistream_withassign@@UAEPAXI at Z  # virtual void * __thiscall istream_withassign::`scalar deleting destructor'(unsigned int)
 @ stub -arch=win32 ??_Gistrstream@@UAEPAXI at Z  # virtual void * __thiscall istrstream::`scalar deleting destructor'(unsigned int)
-@ stub -arch=win32 ??_Glogic_error@@UAEPAXI at Z  # virtual void * __thiscall logic_error::`scalar deleting destructor'(unsigned int)
+@ thiscall -arch=win32 ??_Glogic_error@@UAEPAXI at Z(ptr long) MSVCP_logic_error_scalar_dtor
 @ stub -arch=win32 ??_Gofstream@@UAEPAXI at Z  # virtual void * __thiscall ofstream::`scalar deleting destructor'(unsigned int)
 @ stub -arch=win32 ??_Gostream@@UAEPAXI at Z  # virtual void * __thiscall ostream::`scalar deleting destructor'(unsigned int)
 @ stub -arch=win32 ??_Gostream_withassign@@UAEPAXI at Z  # virtual void * __thiscall ostream_withassign::`scalar deleting destructor'(unsigned int)
@@ -760,8 +760,8 @@
 @ stub ?unlockc at ios@@KAXXZ  # static void __cdecl ios::unlockc(void)
 @ stub -arch=win32 ?unsetf at ios@@QAEJJ at Z  # long __thiscall ios::unsetf(long)
 @ stub -arch=win64 ?unsetf at ios@@QEAAJJ at Z
-@ thiscall -arch=i386 ?what at exception@@UBEPBDXZ(ptr) msvcrt.?what at exception@@UBEPBDXZ
-@ cdecl -arch=win64 ?what at exception@@UEBAPEBDXZ(ptr) msvcrt.?what at exception@@UEBAPEBDXZ
+@ thiscall -arch=i386 ?what at exception@@UBEPBDXZ(ptr) MSVCP_exception_what
+@ cdecl -arch=win64 ?what at exception@@UEBAPEBDXZ(ptr) MSVCP_exception_what
 @ stub -arch=win32 ?width at ios@@QAEHH at Z  # int __thiscall ios::width(int)
 @ stub -arch=win64 ?width at ios@@QEAAHH at Z
 @ stub -arch=win32 ?width at ios@@QBEHXZ  # int __thiscall ios::width(void)const 
diff --git a/dlls/msvcp90/exception.c b/dlls/msvcp90/exception.c
index faeadda..67c73a0 100644
--- a/dlls/msvcp90/exception.c
+++ b/dlls/msvcp90/exception.c
@@ -21,18 +21,21 @@
 #include <stdarg.h>
 
 #include "msvcp90.h"
-
 #include "windef.h"
 #include "winbase.h"
 #include "wine/debug.h"
+#ifdef _MSVCIRT
+WINE_DEFAULT_DEBUG_CHANNEL(msvcirt);
+#else
 WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
+#endif
 
 #define CLASS_IS_SIMPLE_TYPE          1
 #define CLASS_HAS_VIRTUAL_BASE_CLASS  4
 
 void WINAPI _CxxThrowException(exception*,const cxx_exception_type*);
 
-#if _MSVCP_VER >= 70
+#if _MSVCP_VER >= 70 || defined(_MSVCIRT)
 typedef const char **exception_name;
 #define EXCEPTION_STR(name) (*name)
 #define EXCEPTION_NAME(str) ((exception_name)&str)
@@ -48,6 +51,7 @@ extern const vtable_ptr MSVCP_exception_vtable;
 extern const vtable_ptr MSVCP_bad_alloc_vtable;
 /* ??_7logic_error at std@@6B@ */
 extern const vtable_ptr MSVCP_logic_error_vtable;
+#ifndef _MSVCIRT
 /* ??_7length_error at std@@6B@ */
 extern const vtable_ptr MSVCP_length_error_vtable;
 /* ??_7out_of_range at std@@6B@ */
@@ -58,6 +62,7 @@ extern const vtable_ptr MSVCP_runtime_error_vtable;
 extern const vtable_ptr MSVCP_failure_vtable;
 /* ??_7bad_cast at std@@6B@ */
 extern const vtable_ptr MSVCP_bad_cast_vtable;
+#endif
 
 static void MSVCP_type_info_dtor(type_info * _this)
 {
@@ -87,7 +92,12 @@ void * __thiscall MSVCP_type_info_vector_dtor(type_info * _this, unsigned int fl
 
 DEFINE_RTTI_DATA0( type_info, 0, ".?AVtype_info@@" )
 
+#ifdef _MSVCIRT
+DEFINE_THISCALL_WRAPPER(MSVCP_exception_ctor,8)
+exception* __thiscall MSVCP_exception_ctor(exception *this, exception_name name)
+#else
 static exception* MSVCP_exception_ctor(exception *this, exception_name name)
+#endif
 {
     TRACE("(%p %s)\n", this, EXCEPTION_STR(name));
 
@@ -119,6 +129,16 @@ exception* __thiscall MSVCP_exception_copy_ctor(exception *this, const exception
     return this;
 }
 
+DEFINE_THISCALL_WRAPPER(MSVCP_exception_default_ctor,4)
+exception* __thiscall MSVCP_exception_default_ctor(exception *this)
+{
+    TRACE("(%p)\n", this);
+    this->vtable = &MSVCP_exception_vtable;
+    this->name = NULL;
+    this->do_free = FALSE;
+    return this;
+}
+
 DEFINE_THISCALL_WRAPPER(MSVCP_exception_dtor,4)
 void __thiscall MSVCP_exception_dtor(exception *this)
 {
@@ -148,8 +168,21 @@ void * __thiscall MSVCP_exception_vector_dtor(exception *this, unsigned int flag
     return this;
 }
 
-DEFINE_RTTI_DATA0(exception, 0, ".?AVexception at std@@")
-DEFINE_CXX_DATA0(exception, MSVCP_exception_dtor)
+DEFINE_THISCALL_WRAPPER(MSVCP_exception_scalar_dtor, 8)
+void * __thiscall MSVCP_exception_scalar_dtor(exception *this, unsigned int flags)
+{
+    TRACE("(%p %x)\n", this, flags);
+    MSVCP_exception_dtor(this);
+    if (flags & 1) MSVCRT_operator_delete(this);
+    return this;
+}
+
+DEFINE_THISCALL_WRAPPER(MSVCP_exception_assign, 8)
+exception* __thiscall MSVCP_exception_assign(exception *this, const exception *assign)
+{
+    MSVCP_exception_dtor(this);
+    return MSVCP_exception_copy_ctor(this, assign);
+}
 
 /* ?_Doraise at bad_alloc@std@@MBEXXZ */
 /* ?_Doraise at bad_alloc@std@@MEBAXXZ */
@@ -176,6 +209,13 @@ const char* __thiscall MSVCP_exception_what(exception * this)
     return this->name ? this->name : "Unknown exception";
 }
 
+#ifdef _MSVCIRT
+DEFINE_RTTI_DATA0(exception, 0, ".?AVexception at std@@")
+#else
+DEFINE_RTTI_DATA0(exception, 0, ".?AVexception@@")
+#endif
+DEFINE_CXX_DATA0(exception, MSVCP_exception_dtor)
+
 /* bad_alloc class data */
 typedef exception bad_alloc;
 
@@ -254,16 +294,27 @@ DEFINE_CXX_DATA1(bad_alloc, &exception_cxx_type_info, MSVCP_bad_alloc_dtor)
 /* logic_error class data */
 typedef struct {
     exception e;
+#ifndef _MSVCIRT
     basic_string_char str;
+#endif
 } logic_error;
 
+#ifdef _MSVCIRT
+DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_ctor, 8)
+logic_error* __thiscall MSVCP_logic_error_ctor( logic_error *this, exception_name name )
+#else
 static logic_error* MSVCP_logic_error_ctor( logic_error *this, exception_name name )
+#endif
 {
     TRACE("%p %s\n", this, EXCEPTION_STR(name));
-    this->e.vtable = &MSVCP_logic_error_vtable;
+#ifdef _MSVCIRT
+    MSVCP_exception_ctor(&this->e, name);
+#else
     this->e.name = NULL;
     this->e.do_free = FALSE;
     MSVCP_basic_string_char_ctor_cstr(&this->str, EXCEPTION_STR(name));
+#endif
+    this->e.vtable = &MSVCP_logic_error_vtable;
     return this;
 }
 
@@ -275,13 +326,16 @@ logic_error* __thiscall MSVCP_logic_error_copy_ctor(
 {
     TRACE("%p %p\n", this, rhs);
     MSVCP_exception_copy_ctor(&this->e, &rhs->e);
+#ifndef _MSVCIRT
     MSVCP_basic_string_char_copy_ctor(&this->str, &rhs->str);
+#endif
     this->e.vtable = &MSVCP_logic_error_vtable;
     return this;
 }
 
 /* ??0logic_error at std@@QAE at ABV?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@1@@Z */
 /* ??0logic_error at std@@QEAA at AEBV?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@1@@Z */
+#ifndef _MSVCIRT
 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_ctor_bstr, 8)
 logic_error* __thiscall MSVCP_logic_error_ctor_bstr(logic_error *this, const basic_string_char *str)
 {
@@ -289,6 +343,7 @@ logic_error* __thiscall MSVCP_logic_error_ctor_bstr(logic_error *this, const bas
     TRACE("(%p %p %s)\n", this, str, name);
     return MSVCP_logic_error_ctor(this, EXCEPTION_NAME(name));
 }
+#endif
 
 /* ??1logic_error at std@@UAE at XZ */
 /* ??1logic_error at std@@UEAA at XZ */
@@ -301,7 +356,9 @@ void __thiscall MSVCP_logic_error_dtor(logic_error *this)
 {
     TRACE("%p\n", this);
     MSVCP_exception_dtor(&this->e);
+#ifndef _MSVCIRT
     MSVCP_basic_string_char_dtor(&this->str);
+#endif
 }
 
 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_vector_dtor, 8)
@@ -325,6 +382,15 @@ void* __thiscall MSVCP_logic_error_vector_dtor(
     return this;
 }
 
+DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_scalar_dtor, 8)
+void * __thiscall MSVCP_logic_error_scalar_dtor(logic_error *this, unsigned int flags)
+{
+    TRACE("(%p %x)\n", this, flags);
+    MSVCP_logic_error_dtor(this);
+    if (flags & 1) MSVCRT_operator_delete(this);
+    return this;
+}
+
 /* ??4logic_error at std@@QAEAAV01 at ABV01@@Z */
 /* ??4logic_error at std@@QEAAAEAV01 at AEBV01@@Z */
 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_assign, 8)
@@ -336,16 +402,24 @@ logic_error* __thiscall MSVCP_logic_error_assign(logic_error *this, const logic_
 
 /* ?what at logic_error@std@@UBEPBDXZ */
 /* ?what at logic_error@std@@UEBAPEBDXZ */
+#ifndef _MSVCIRT
 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_what, 4)
 const char* __thiscall MSVCP_logic_error_what(logic_error *this)
 {
     TRACE("%p\n", this);
     return MSVCP_basic_string_char_c_str(&this->str);
 }
+#endif
 
+#ifdef _MSVCIRT
 DEFINE_RTTI_DATA1(logic_error, 0, &exception_rtti_base_descriptor, ".?AVlogic_error at std@@")
+#else
+DEFINE_RTTI_DATA1(logic_error, 0, &exception_rtti_base_descriptor, ".?AVlogic_error@@")
+#endif
 DEFINE_CXX_DATA1(logic_error, &exception_cxx_type_info, MSVCP_logic_error_dtor)
 
+#ifndef _MSVCIRT
+
 /* length_error class data */
 typedef logic_error length_error;
 
@@ -728,7 +802,9 @@ MSVCP_bool __cdecl MSVCP__uncaught_exception(void)
     return __uncaught_exception();
 }
 
-#if _MSVCP_VER >= 70
+#endif /* _MSVCIRT */
+
+#if _MSVCP_VER >= 70 || defined(_MSVCIRT)
 #define EXCEPTION_VTABLE(name,funcs) __ASM_VTABLE(name,funcs)
 #else
 #define EXCEPTION_VTABLE(name,funcs) __ASM_VTABLE(name,funcs VTABLE_ADD_FUNC(MSVCP_exception__Doraise))
@@ -747,6 +823,9 @@ void __asm_dummy_vtables(void) {
             VTABLE_ADD_FUNC(MSVCP_exception_what));
     EXCEPTION_VTABLE(logic_error,
             VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
+#ifdef _MSVCIRT
+            VTABLE_ADD_FUNC(MSVCP_exception_what));
+#else
             VTABLE_ADD_FUNC(MSVCP_logic_error_what));
     EXCEPTION_VTABLE(length_error,
             VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
@@ -766,6 +845,7 @@ void __asm_dummy_vtables(void) {
     EXCEPTION_VTABLE(bad_cast,
             VTABLE_ADD_FUNC(MSVCP_bad_cast_vector_dtor)
             VTABLE_ADD_FUNC(MSVCP_exception_what));
+#endif
 #ifndef __GNUC__
 }
 #endif
@@ -788,16 +868,12 @@ void throw_exception(exception_type et, const char *str)
         MSVCP_bad_alloc_ctor(&e, name);
         _CxxThrowException(&e, &bad_alloc_cxx_type);
     }
-    case EXCEPTION_BAD_CAST: {
-        bad_cast e;
-        MSVCP_bad_cast_ctor(&e, str);
-        _CxxThrowException(&e, &bad_cast_cxx_type);
-    }
     case EXCEPTION_LOGIC_ERROR: {
         logic_error e;
         MSVCP_logic_error_ctor(&e, name);
         _CxxThrowException((exception*)&e, &logic_error_cxx_type);
     }
+#ifndef _MSVCIRT
     case EXCEPTION_LENGTH_ERROR: {
         length_error e;
         MSVCP_length_error_ctor(&e, name);
@@ -823,6 +899,14 @@ void throw_exception(exception_type et, const char *str)
         MSVCP_failure_ctor(&e, name);
         _CxxThrowException((exception*)&e, &failure_cxx_type);
     }
+    case EXCEPTION_BAD_CAST: {
+        bad_cast e;
+        MSVCP_bad_cast_ctor(&e, str);
+        _CxxThrowException(&e, &bad_cast_cxx_type);
+    }
+#else
+    default: break;
+#endif
     }
 }
 
@@ -833,6 +917,11 @@ void init_exception(void *base)
     init_exception_rtti(base);
     init_bad_alloc_rtti(base);
     init_logic_error_rtti(base);
+
+    init_exception_cxx(base);
+    init_bad_alloc_cxx(base);
+    init_logic_error_cxx(base);
+#ifndef _MSVCIRT
     init_length_error_rtti(base);
     init_out_of_range_rtti(base);
     init_invalid_argument_rtti(base);
@@ -840,9 +929,6 @@ void init_exception(void *base)
     init_failure_rtti(base);
     init_bad_cast_rtti(base);
 
-    init_exception_cxx(base);
-    init_bad_alloc_cxx(base);
-    init_logic_error_cxx(base);
     init_length_error_cxx(base);
     init_out_of_range_cxx(base);
     init_invalid_argument_cxx(base);
@@ -850,4 +936,5 @@ void init_exception(void *base)
     init_failure_cxx(base);
     init_bad_cast_cxx(base);
 #endif
+#endif
 }
-- 
2.1.4




More information about the wine-patches mailing list