Module: wine Branch: master Commit: d87d101af995d3817d32b72dd5a2187c066d3b70 URL: https://gitlab.winehq.org/wine/wine/-/commit/d87d101af995d3817d32b72dd5a2187...
Author: Piotr Caban piotr@codeweavers.com Date: Tue Sep 12 20:29:33 2023 +0200
msvcp100: Fix failure class layout.
---
dlls/msvcp90/exception.c | 14 +++------- dlls/msvcp90/misc.c | 70 +++++++++++++++++++++++++++++++----------------- dlls/msvcp90/msvcp90.h | 14 ++++++++++ 3 files changed, 63 insertions(+), 35 deletions(-)
diff --git a/dlls/msvcp90/exception.c b/dlls/msvcp90/exception.c index 63c698f3c6c..949b896bb2e 100644 --- a/dlls/msvcp90/exception.c +++ b/dlls/msvcp90/exception.c @@ -637,7 +637,7 @@ DEFINE_CXX_DATA1(runtime_error, &exception_cxx_type_info, MSVCP_runtime_error_dt typedef struct { runtime_error base; #if _MSVCP_VER > 90 - int err; + error_code code; #endif } system_error; typedef system_error _System_error; @@ -648,8 +648,8 @@ static failure* MSVCP_failure_ctor( failure *this, exception_name name ) TRACE("%p %s\n", this, EXCEPTION_STR(name)); MSVCP_runtime_error_ctor(&this->base, name); #if _MSVCP_VER > 90 - /* FIXME: set err correctly */ - this->err = 0; + this->code.code = 1; + this->code.category = std_iostream_category(); #endif this->base.e.vtable = &failure_vtable; return this; @@ -662,7 +662,7 @@ failure* __thiscall failure_copy_ctor( TRACE("%p %p\n", this, rhs); runtime_error_copy_ctor(&this->base, &rhs->base); #if _MSVCP_VER > 90 - this->err = rhs->err; + this->code = rhs->code; #endif this->base.e.vtable = &failure_vtable; return this; @@ -948,12 +948,6 @@ bool __cdecl MSVCP__uncaught_exception(void) }
#if _MSVCP_VER >= 110 -typedef struct -{ - int code; - void *category; -} error_code; - typedef struct { logic_error base; diff --git a/dlls/msvcp90/misc.c b/dlls/msvcp90/misc.c index 103eca6f4a3..8b9514c6edb 100644 --- a/dlls/msvcp90/misc.c +++ b/dlls/msvcp90/misc.c @@ -997,11 +997,7 @@ void __cdecl _Cnd_do_broadcast_at_thread_exit(void)
#endif
-#if _MSVCP_VER == 100 -typedef struct { - const vtable_ptr *vtable; -} error_category; - +#if _MSVCP_VER >= 100 typedef struct { error_category base; const char *type; @@ -1009,14 +1005,22 @@ typedef struct { static custom_category iostream_category;
DEFINE_RTTI_DATA0(error_category, 0, ".?AVerror_category@std@@") +DEFINE_RTTI_DATA1(generic_category, 0, &error_category_rtti_base_descriptor, ".?AV_Generic_error_category@std@@") +#if _MSVCP_VER == 100 DEFINE_RTTI_DATA1(iostream_category, 0, &error_category_rtti_base_descriptor, ".?AV_Iostream_error_category@std@@") +#else +DEFINE_RTTI_DATA2(iostream_category, 0, &generic_category_rtti_base_descriptor, + &error_category_rtti_base_descriptor, ".?AV_Iostream_error_category@std@@") +#endif
extern const vtable_ptr iostream_category_vtable;
static void iostream_category_ctor(custom_category *this) { this->base.vtable = &iostream_category_vtable; +#if _MSVCP_VER == 100 this->type = "iostream"; +#endif }
DEFINE_THISCALL_WRAPPER(custom_category_vector_dtor, 8) @@ -1037,19 +1041,6 @@ custom_category* __thiscall custom_category_vector_dtor(custom_category *this, u return this; }
-DEFINE_THISCALL_WRAPPER(custom_category_name, 4) -const char* __thiscall custom_category_name(const custom_category *this) -{ - return this->type; -} - -DEFINE_THISCALL_WRAPPER(custom_category_message, 12) -basic_string_char* __thiscall custom_category_message(const custom_category *this, - basic_string_char *ret, int err) -{ - return MSVCP_basic_string_char_ctor_cstr(ret, strerror(err)); -} - DEFINE_THISCALL_WRAPPER(custom_category_default_error_condition, 12) /*error_condition*/void* __thiscall custom_category_default_error_condition( custom_category *this, /*error_condition*/void *ret, int code) @@ -1068,12 +1059,22 @@ bool __thiscall custom_category_equivalent(const custom_category *this,
DEFINE_THISCALL_WRAPPER(custom_category_equivalent_code, 12) bool __thiscall custom_category_equivalent_code(custom_category *this, - const /*error_code*/void *code, int condition) + const error_code *code, int condition) { FIXME("(%p %p %x) stub\n", this, code, condition); return FALSE; }
+DEFINE_THISCALL_WRAPPER(iostream_category_name, 4) +const char* __thiscall iostream_category_name(const custom_category *this) +{ +#if _MSVCP_VER == 100 + return this->type; +#else + return "iostream"; +#endif +} + DEFINE_THISCALL_WRAPPER(iostream_category_message, 12) basic_string_char* __thiscall iostream_category_message(const custom_category *this, basic_string_char *ret, int err) @@ -1089,7 +1090,9 @@ const error_category* __cdecl std_iostream_category(void) TRACE("()\n"); return &iostream_category.base; } +#endif
+#if _MSVCP_VER == 100 static custom_category system_category; DEFINE_RTTI_DATA1(system_category, 0, &error_category_rtti_base_descriptor, ".?AV_System_error_category@std@@")
@@ -1101,6 +1104,19 @@ static void system_category_ctor(custom_category *this) this->type = "system"; }
+DEFINE_THISCALL_WRAPPER(custom_category_name, 4) +const char* __thiscall custom_category_name(const custom_category *this) +{ + return this->type; +} + +DEFINE_THISCALL_WRAPPER(custom_category_message, 12) +basic_string_char* __thiscall custom_category_message(const custom_category *this, + basic_string_char *ret, int err) +{ + return MSVCP_basic_string_char_ctor_cstr(ret, strerror(err)); +} + /* ?system_category@std@@YAABVerror_category@1@XZ */ /* ?system_category@std@@YAAEBVerror_category@1@XZ */ const error_category* __cdecl std_system_category(void) @@ -1110,7 +1126,6 @@ const error_category* __cdecl std_system_category(void) }
static custom_category generic_category; -DEFINE_RTTI_DATA1(generic_category, 0, &error_category_rtti_base_descriptor, ".?AV_Generic_error_category@std@@")
extern const vtable_ptr generic_category_vtable;
@@ -1686,14 +1701,14 @@ int __cdecl _Winerror_map(int err)
#if _MSVCP_VER >= 100 __ASM_BLOCK_BEGIN(misc_vtables) -#if _MSVCP_VER == 100 __ASM_VTABLE(iostream_category, VTABLE_ADD_FUNC(custom_category_vector_dtor) - VTABLE_ADD_FUNC(custom_category_name) + VTABLE_ADD_FUNC(iostream_category_name) VTABLE_ADD_FUNC(iostream_category_message) VTABLE_ADD_FUNC(custom_category_default_error_condition) VTABLE_ADD_FUNC(custom_category_equivalent) VTABLE_ADD_FUNC(custom_category_equivalent_code)); +#if _MSVCP_VER == 100 __ASM_VTABLE(system_category, VTABLE_ADD_FUNC(custom_category_vector_dtor) VTABLE_ADD_FUNC(custom_category_name) @@ -1718,19 +1733,24 @@ __ASM_BLOCK_END void init_misc(void *base) { #ifdef __x86_64__ -#if _MSVCP_VER == 100 +#if _MSVCP_VER >= 100 init_error_category_rtti(base); + init_generic_category_rtti(base); init_iostream_category_rtti(base); +#endif +#if _MSVCP_VER == 100 init_system_category_rtti(base); - init_generic_category_rtti(base); #endif #if _MSVCP_VER >= 110 init__Pad_rtti(base); #endif #endif
-#if _MSVCP_VER == 100 +#if _MSVCP_VER >= 100 iostream_category_ctor(&iostream_category); +#endif + +#if _MSVCP_VER == 100 system_category_ctor(&system_category); generic_category_ctor(&generic_category); #endif diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h index c9e8e05566c..a674d0704b1 100644 --- a/dlls/msvcp90/msvcp90.h +++ b/dlls/msvcp90/msvcp90.h @@ -668,6 +668,20 @@ typedef struct { double imag; } complex_double;
+#if _MSVCP_VER >= 100 +typedef struct { + const vtable_ptr *vtable; +} error_category; + +const error_category* __cdecl std_iostream_category(void); + +typedef struct +{ + int code; + const error_category *category; +} error_code; +#endif + #if _MSVCP_VER < 80 static inline int memcpy_wrapper( void *dst, size_t size, const void *src, size_t count ) {