It's not available on XP, so we need to provice a compat implementation for libmsvcrt-os.a.
Signed-off-by: Jacek Caban <ja...@codeweavers.com> --- mingw-w64-crt/Makefile.am | 5 +- mingw-w64-crt/lib-common/msvcrt.def.in | 2 +- mingw-w64-crt/lib32/msvcr100.def.in | 2 +- mingw-w64-crt/lib32/msvcr80.def.in | 1 + mingw-w64-crt/lib32/msvcr90.def.in | 2 +- mingw-w64-crt/lib32/msvcr90d.def.in | 2 +- mingw-w64-crt/lib64/msvcr100.def.in | 2 +- mingw-w64-crt/lib64/msvcr80.def.in | 1 + mingw-w64-crt/lib64/msvcr90.def.in | 2 +- mingw-w64-crt/lib64/msvcr90d.def.in | 2 +- mingw-w64-crt/misc/wassert.c | 72 +++++++++++++------------- mingw-w64-headers/crt/assert.h | 3 +- 12 files changed, 49 insertions(+), 47 deletions(-)
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index 0af497af..e7de216d 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -231,7 +231,8 @@ src_ucrtbase=\ src_msvcrt32=\ $(src_msvcrt) \ - misc/lc_locale_func.c + misc/lc_locale_func.c \ + misc/wassert.c src_msvcrt64=\ $(src_msvcrt) \ @@ -327,7 +328,7 @@ src_libmingwex=\ misc/spawnve.c misc/spawnvp.c misc/spawnvpe.c misc/strnlen.c misc/strsafe.c \ misc/strtoimax.c misc/strtold.c misc/strtoumax.c misc/tdelete.c misc/tfind.c \ misc/tsearch.c misc/twalk.c misc/uchar_c16rtomb.c misc/uchar_c32rtomb.c misc/uchar_mbrtoc16.c \ - misc/uchar_mbrtoc32.c misc/wassert.c misc/wcrtomb.c misc/wcsnlen.c misc/wcstof.c \ + misc/uchar_mbrtoc32.c misc/wcrtomb.c misc/wcsnlen.c misc/wcstof.c \ misc/wcstoimax.c misc/wcstold.c misc/wcstoumax.c misc/wctob.c misc/wctrans.c \ misc/wctype.c misc/wdirent.c misc/winbs_uint64.c misc/winbs_ulong.c misc/winbs_ushort.c \ misc/wmemchr.c misc/wmemcmp.c misc/wmemcpy.c misc/wmemmove.c misc/wmempcpy.c \ diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in b/mingw-w64-crt/lib-common/msvcrt.def.in index 449beb0a..e271d2e3 100644 --- a/mingw-w64-crt/lib-common/msvcrt.def.in +++ b/mingw-w64-crt/lib-common/msvcrt.def.in @@ -1138,7 +1138,7 @@ _waccess ; _waccess_s Replaced by emu _wasctime ; _wasctime_s Replaced by emu -F_ARM_ANY(_wassert) +F_NON_I386(_wassert) _wchdir _wchmod _wcmdln DATA diff --git a/mingw-w64-crt/lib32/msvcr100.def.in b/mingw-w64-crt/lib32/msvcr100.def.in index 1c6ae3dc..9c149db1 100644 --- a/mingw-w64-crt/lib32/msvcr100.def.in +++ b/mingw-w64-crt/lib32/msvcr100.def.in @@ -1519,7 +1519,7 @@ _waccess _waccess_s _wasctime _wasctime_s -_wassert DATA +_wassert _wchdir _wchmod _wcmdln DATA diff --git a/mingw-w64-crt/lib32/msvcr80.def.in b/mingw-w64-crt/lib32/msvcr80.def.in index f5e95550..d0776d8f 100644 --- a/mingw-w64-crt/lib32/msvcr80.def.in +++ b/mingw-w64-crt/lib32/msvcr80.def.in @@ -800,6 +800,7 @@ _strtoui64 _ungetwch _vscprintf _vscwprintf +_wassert _wcserror _wcstoi64 _wcstoui64 diff --git a/mingw-w64-crt/lib32/msvcr90.def.in b/mingw-w64-crt/lib32/msvcr90.def.in index c341951a..c7e67aea 100644 --- a/mingw-w64-crt/lib32/msvcr90.def.in +++ b/mingw-w64-crt/lib32/msvcr90.def.in @@ -1153,7 +1153,7 @@ _waccess _waccess_s _wasctime _wasctime_s -_wassert DATA +_wassert _wchdir _wchmod _wcmdln DATA diff --git a/mingw-w64-crt/lib32/msvcr90d.def.in b/mingw-w64-crt/lib32/msvcr90d.def.in index 2fe211dd..e54acf63 100644 --- a/mingw-w64-crt/lib32/msvcr90d.def.in +++ b/mingw-w64-crt/lib32/msvcr90d.def.in @@ -1219,7 +1219,7 @@ _waccess _waccess_s _wasctime _wasctime_s -_wassert DATA +_wassert _wchdir _wchmod _wcmdln DATA diff --git a/mingw-w64-crt/lib64/msvcr100.def.in b/mingw-w64-crt/lib64/msvcr100.def.in index 68c09d6c..48fc5a8d 100644 --- a/mingw-w64-crt/lib64/msvcr100.def.in +++ b/mingw-w64-crt/lib64/msvcr100.def.in @@ -1466,7 +1466,7 @@ _waccess _waccess_s _wasctime _wasctime_s -_wassert DATA +_wassert _wchdir _wchmod _wcmdln DATA diff --git a/mingw-w64-crt/lib64/msvcr80.def.in b/mingw-w64-crt/lib64/msvcr80.def.in index 2372e2e6..7e05606e 100644 --- a/mingw-w64-crt/lib64/msvcr80.def.in +++ b/mingw-w64-crt/lib64/msvcr80.def.in @@ -557,6 +557,7 @@ vsnprintf == _vsnprintf _vsnwprintf _waccess _wasctime +_wassert _wchdir _wchmod _wcmdln DATA diff --git a/mingw-w64-crt/lib64/msvcr90.def.in b/mingw-w64-crt/lib64/msvcr90.def.in index cf01dc0c..ec087968 100644 --- a/mingw-w64-crt/lib64/msvcr90.def.in +++ b/mingw-w64-crt/lib64/msvcr90.def.in @@ -1086,7 +1086,7 @@ _waccess _waccess_s _wasctime _wasctime_s -_wassert DATA +_wassert _wchdir _wchmod _wcmdln DATA diff --git a/mingw-w64-crt/lib64/msvcr90d.def.in b/mingw-w64-crt/lib64/msvcr90d.def.in index 99b167ee..e40b3691 100644 --- a/mingw-w64-crt/lib64/msvcr90d.def.in +++ b/mingw-w64-crt/lib64/msvcr90d.def.in @@ -1146,7 +1146,7 @@ _waccess _waccess_s _wasctime _wasctime_s -_wassert DATA +_wassert _wchdir _wchmod _wcmdln DATA diff --git a/mingw-w64-crt/misc/wassert.c b/mingw-w64-crt/misc/wassert.c index 7d745d92..2fdd5e29 100644 --- a/mingw-w64-crt/misc/wassert.c +++ b/mingw-w64-crt/misc/wassert.c @@ -3,47 +3,47 @@ * This file is part of the mingw-w64 runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ -#include <windows.h> -#include <stdio.h> -#include <stdlib.h> -#include <wchar.h> -#include <signal.h> -extern int mingw_app_type; - -void __cdecl _wassert (const wchar_t *, const wchar_t *,unsigned); -void __cdecl _assert (const char *, const char *, unsigned); +#include <assert.h> +#include <stdlib.h> +#include <windows.h> +#include "msvcrt.h" -void __cdecl -_wassert (const wchar_t *_Message, const wchar_t *_File, unsigned _Line) +/* _wassert is not available on XP, so forward it to _assert if needed */ +static void __cdecl mingw_wassert(const wchar_t *_Message, const wchar_t *_File, unsigned _Line) { - wchar_t *msgbuf = (wchar_t *) malloc (8192*sizeof(wchar_t)); - wchar_t fn[MAX_PATH + 1]; - DWORD nCode; - - if (!_File || _File[0] == 0) - _File = L"<unknown>"; - if (!_Message || _Message[0] == 0) - _Message = L"?"; - if (! GetModuleFileNameW (NULL, fn, MAX_PATH)) - wcscpy (fn, L"<unknown>"); - _snwprintf (msgbuf, 8191, L"Assertion failed!\n\nProgram: %ws\n" - "File: %ws, Line %u\n\nExpression: %ws", - fn, _File,_Line, _Message); - if (mingw_app_type == 0) + char *message = NULL, *file = NULL; + size_t len; + + if ((len = wcstombs(NULL, _Message, 0)) != (size_t)-1) { - fwprintf (stderr, L"%ws\n", msgbuf); - abort (); + message = malloc(len + 1); + wcstombs(message, _Message, len + 1); } - nCode = MessageBoxW (NULL, msgbuf, L"MinGW Runtime Assertion", MB_ABORTRETRYIGNORE| - MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL); - if (nCode == IDABORT) + + if ((len = wcstombs(NULL, _File, 0)) != (size_t)-1) { - raise (SIGABRT); - _exit (3); - abort (); + file = malloc(len + 1); + wcstombs(file, _File, len + 1); } - if (nCode == IDIGNORE) - return; - abort (); + + _assert(message, file, _Line); + + free(message); + free(file); +} + +static void __cdecl init_wassert(const wchar_t *message, const wchar_t *file, unsigned line); + +void (__cdecl *__MINGW_IMP_SYMBOL(_wassert))(const wchar_t*, const wchar_t*,unsigned) = init_wassert; + +static void __cdecl init_wassert(const wchar_t *message, const wchar_t *file, unsigned line) +{ + void *func; + + func = (void*)GetProcAddress(__mingw_get_msvcrt_handle(), "_wassert"); + if(!func) + func = mingw_wassert; + + return (__MINGW_IMP_SYMBOL(_wassert) = func)(message, file, line); } diff --git a/mingw-w64-headers/crt/assert.h b/mingw-w64-headers/crt/assert.h index 4004a959..fce63a03 100644 --- a/mingw-w64-headers/crt/assert.h +++ b/mingw-w64-headers/crt/assert.h @@ -42,8 +42,7 @@ extern "C" { #endif /* _CRT_TERMINATE_DEFINED */ -extern void __cdecl -_wassert(const wchar_t *_Message,const wchar_t *_File,unsigned _Line); +_CRTIMP void __cdecl _wassert(const wchar_t *_Message,const wchar_t *_File,unsigned _Line); _CRTIMP void __cdecl _assert (const char *_Message, const char *_File, unsigned _Line); #ifdef __cplusplus
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public