-- v2: msvcp140: Recognize no error case in _Syserror_map. msvcp140/tests: Fix _Syserror_map(0) test failure in newest msvcp140.
From: Vijay Kiran Kamuju infyquest@gmail.com
--- dlls/msvcp140/msvcp140.spec | 2 +- dlls/msvcp90/exception.c | 8 ++++++++ dlls/msvcp_win/msvcp_win.spec | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcp140/msvcp140.spec b/dlls/msvcp140/msvcp140.spec index c04e870eb72..bc18d7b5be8 100644 --- a/dlls/msvcp140/msvcp140.spec +++ b/dlls/msvcp140/msvcp140.spec @@ -1672,7 +1672,7 @@ @ cdecl ?_Winerror_map@std@@YAHH@Z(long) _Winerror_map @ cdecl -arch=win32 ?_Winerror_message@std@@YAKKPADK@Z(long ptr long) _Winerror_message @ cdecl -arch=win64 ?_Winerror_message@std@@YAKKPEADK@Z(long ptr long) _Winerror_message -@ stub ?_XGetLastError@std@@YAXXZ +@ cdecl ?_XGetLastError@std@@YAXXZ() _XGetLastError @ cdecl ?_XLgamma@std@@YAMM@Z(float) std__XLgamma_float @ cdecl ?_XLgamma@std@@YANN@Z(double) std__XLgamma_double @ cdecl ?_XLgamma@std@@YAOO@Z(double) std__XLgamma_double diff --git a/dlls/msvcp90/exception.c b/dlls/msvcp90/exception.c index 01cb2bb5dab..4cfa70c4c72 100644 --- a/dlls/msvcp90/exception.c +++ b/dlls/msvcp90/exception.c @@ -997,6 +997,14 @@ bool __cdecl MSVCP__uncaught_exception(void) return __uncaught_exception(); }
+#if _MSVCP_VER >= 140 +/* ?_XGetLastError@std@@YAXXZ */ +void __cdecl _XGetLastError(void) +{ + FIXME("stub\n"); +} +#endif + #if _MSVCP_VER >= 110 typedef struct { diff --git a/dlls/msvcp_win/msvcp_win.spec b/dlls/msvcp_win/msvcp_win.spec index 813d2ba67da..71dc2c1e953 100644 --- a/dlls/msvcp_win/msvcp_win.spec +++ b/dlls/msvcp_win/msvcp_win.spec @@ -1672,7 +1672,7 @@ @ cdecl ?_Winerror_map@std@@YAHH@Z(long) msvcp140.?_Winerror_map@std@@YAHH@Z @ cdecl -arch=win32 ?_Winerror_message@std@@YAKKPADK@Z(long ptr long) msvcp140.?_Winerror_message@std@@YAKKPADK@Z @ cdecl -arch=win64 ?_Winerror_message@std@@YAKKPEADK@Z(long ptr long) msvcp140.?_Winerror_message@std@@YAKKPEADK@Z -@ stub ?_XGetLastError@std@@YAXXZ +@ cdecl ?_XGetLastError@std@@YAXXZ() msvcp140.?_XGetLastError@std@@YAXXZ @ cdecl ?_XLgamma@std@@YAMM@Z(float) msvcp140.?_XLgamma@std@@YAMM@Z @ cdecl ?_XLgamma@std@@YANN@Z(double) msvcp140.?_XLgamma@std@@YANN@Z @ cdecl ?_XLgamma@std@@YAOO@Z(double) msvcp140.?_XLgamma@std@@YAOO@Z
From: Piotr Caban piotr@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46904 --- dlls/msvcp90/exception.c | 14 +++++++++++- dlls/msvcp90/misc.c | 49 ++++++++++++++++++++++++++++------------ dlls/msvcp90/msvcp90.h | 3 +++ 3 files changed, 50 insertions(+), 16 deletions(-)
diff --git a/dlls/msvcp90/exception.c b/dlls/msvcp90/exception.c index 4cfa70c4c72..c881b37cd97 100644 --- a/dlls/msvcp90/exception.c +++ b/dlls/msvcp90/exception.c @@ -1001,7 +1001,19 @@ bool __cdecl MSVCP__uncaught_exception(void) /* ?_XGetLastError@std@@YAXXZ */ void __cdecl _XGetLastError(void) { - FIXME("stub\n"); + int err = GetLastError(); + system_error se; + const char *msg; + + TRACE("() GetLastError()=%d\n", err); + + msg = _Winerror_map_str(err); + MSVCP_runtime_error_ctor(&se.base, &msg); + se.code.code = err; + se.code.category = std_system_category(); + se.base.e.vtable = &system_error_vtable; + + _CxxThrowException(&se, &system_error_cxx_type); } #endif
diff --git a/dlls/msvcp90/misc.c b/dlls/msvcp90/misc.c index f82456cbf4b..a08101052da 100644 --- a/dlls/msvcp90/misc.c +++ b/dlls/msvcp90/misc.c @@ -1063,6 +1063,13 @@ bool __thiscall custom_category_equivalent_code(custom_category *this, return FALSE; }
+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(iostream_category_name, 4) const char* __thiscall iostream_category_name(const custom_category *this) { @@ -1090,7 +1097,7 @@ const error_category* __cdecl std_iostream_category(void) } #endif
-#if _MSVCP_VER == 100 +#if _MSVCP_VER == 100 || _MSVCP_VER >= 140 static custom_category system_category; DEFINE_RTTI_DATA1(system_category, 0, &error_category_rtti_base_descriptor, ".?AV_System_error_category@std@@")
@@ -1099,13 +1106,32 @@ extern const vtable_ptr system_category_vtable; static void system_category_ctor(custom_category *this) { this->base.vtable = &system_category_vtable; +#if _MSVCP_VER == 100 this->type = "system"; +#endif }
-DEFINE_THISCALL_WRAPPER(custom_category_name, 4) -const char* __thiscall custom_category_name(const custom_category *this) +DEFINE_THISCALL_WRAPPER(system_category_name, 4) +const char* __thiscall system_category_name(const custom_category *this) { +#if _MSVCP_VER == 100 return this->type; +#else + return "system"; +#endif +} + +DEFINE_THISCALL_WRAPPER(system_category_message, 12) +basic_string_char* __thiscall system_category_message(const custom_category *this, + basic_string_char *ret, int err) +{ +#if _MSVCP_VER > 100 + const char *msg = _Winerror_map_str(err); + if (!msg) return MSVCP_basic_string_char_ctor_cstr(ret, "unknown error"); + return MSVCP_basic_string_char_ctor_cstr(ret, msg); +#else + return custom_category_message(this, ret, err); +#endif }
/* ?system_category@std@@YAABVerror_category@1@XZ */ @@ -1140,13 +1166,6 @@ const char* __thiscall generic_category_name(const custom_category *this) #endif }
-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)); -} - /* ?generic_category@std@@YAABVerror_category@1@XZ */ /* ?generic_category@std@@YAAEBVerror_category@1@XZ */ const error_category* __cdecl std_generic_category(void) @@ -1729,11 +1748,11 @@ __ASM_BLOCK_BEGIN(misc_vtables) 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 +#if _MSVCP_VER == 100 || _MSVCP_VER >= 140 __ASM_VTABLE(system_category, VTABLE_ADD_FUNC(custom_category_vector_dtor) - VTABLE_ADD_FUNC(custom_category_name) - VTABLE_ADD_FUNC(custom_category_message) + VTABLE_ADD_FUNC(system_category_name) + VTABLE_ADD_FUNC(system_category_message) VTABLE_ADD_FUNC(custom_category_default_error_condition) VTABLE_ADD_FUNC(custom_category_equivalent) VTABLE_ADD_FUNC(custom_category_equivalent_code)); @@ -1759,7 +1778,7 @@ void init_misc(void *base) init_generic_category_rtti(base); init_iostream_category_rtti(base); #endif -#if _MSVCP_VER == 100 +#if _MSVCP_VER == 100 || _MSVCP_VER >= 140 init_system_category_rtti(base); #endif #if _MSVCP_VER >= 110 @@ -1772,7 +1791,7 @@ void init_misc(void *base) generic_category_ctor(&generic_category); #endif
-#if _MSVCP_VER == 100 +#if _MSVCP_VER == 100 || _MSVCP_VER >= 140 system_category_ctor(&system_category); #endif } diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h index 3b97cfefd4b..9471b896ba5 100644 --- a/dlls/msvcp90/msvcp90.h +++ b/dlls/msvcp90/msvcp90.h @@ -694,12 +694,15 @@ typedef struct {
const error_category* __cdecl std_iostream_category(void); const error_category* __cdecl std_generic_category(void); +const error_category* __cdecl std_system_category(void);
typedef struct { int code; const error_category *category; } error_code; + +const char *_Winerror_map_str(int err); #endif
#if _MSVCP_VER < 80
From: Piotr Caban piotr@codeweavers.com
--- dlls/msvcp140/tests/msvcp140.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/msvcp140/tests/msvcp140.c b/dlls/msvcp140/tests/msvcp140.c index 6affa2f9c29..0140d4c3925 100644 --- a/dlls/msvcp140/tests/msvcp140.c +++ b/dlls/msvcp140/tests/msvcp140.c @@ -1396,6 +1396,8 @@ static void test__Syserror_map(void)
r1 = p__Syserror_map(0); ok(r1 != NULL, "_Syserror_map(0) returned NULL\n"); + r1 = p__Syserror_map(1233); + ok(r1 != NULL, "_Syserror_map(1233) returned NULL\n"); r2 = p__Syserror_map(1234); ok(r2 != NULL, "_Syserror_map(1234) returned NULL\n"); ok(r1 == r2, "r1 = %p(%s), r2 = %p(%s)\n", r1, r1, r2, r2);
From: Piotr Caban piotr@codeweavers.com
--- dlls/msvcp90/misc.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/msvcp90/misc.c b/dlls/msvcp90/misc.c index a08101052da..3ae190abeb3 100644 --- a/dlls/msvcp90/misc.c +++ b/dlls/msvcp90/misc.c @@ -28,6 +28,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
#if _MSVCP_VER >= 110 /* error strings generated with glibc strerror */ +#if _MSVCP_VER >= 140 +static const char str_SUCC[] = "success"; +#endif static const char str_EPERM[] = "operation not permitted"; static const char str_ENOENT[] = "no such file or directory"; static const char str_ESRCH[] = "no such process"; @@ -112,6 +115,9 @@ static const struct { const char *str; } syserror_map[] = { +#if _MSVCP_VER >= 140 + {0, str_SUCC}, +#endif {EPERM, str_EPERM}, {ENOENT, str_ENOENT}, {ESRCH, str_ESRCH},
This merge request was approved by Piotr Caban.