Re: [Mingw-w64-public] [PATCH] headers: Fix the declaration of _vscprintf
On 09/29/2017 08:48 PM, Martin Storsjö wrote: > Previously, the ifdefs were misplaced, leading to this function not > being defined at all if building with __USE_MINGW_ANSI_STDIO=1. > > If targeting ucrtbase.dll, we always need to rely on the > __stdio_common_vsprintf implementation, since _vscprintf doesn't > exist in ucrtbase.dll, regardless of the state of the > __USE_MINGW_ANSI_STDIO define. > Patch OK. signature.asc Description: OpenPGP digital signature -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] [PATCHv3] crt: Avoid optimizing fprintf calls into fwrite in crt startup code
On Fri, 29 Sep 2017, Martin Storsjö wrote: By avoiding turning fprintf(stderr,) into fwrite(stderr,) we can localize the compat wrapping for that to fprintf. Then we shouldn't ever need to worry about functions needing init_compat to be called before they're invoked by the constructor. This allows simplifying the ucrtbase_compat.c code quite significantly. Signed-off-by: Martin Storsjö--- Moved the -fno-builtin-fprintf to lib*_libmingw32_a_CFLAGS. --- mingw-w64-crt/Makefile.am | 4 mingw-w64-crt/crt/ucrtbase_compat.c | 42 + 2 files changed, 5 insertions(+), 41 deletions(-) This was ok'd by Jacek on irc, so pushing. // Martin -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] [PATCH] headers: Fix the declaration of _vscprintf
Previously, the ifdefs were misplaced, leading to this function not being defined at all if building with __USE_MINGW_ANSI_STDIO=1. If targeting ucrtbase.dll, we always need to rely on the __stdio_common_vsprintf implementation, since _vscprintf doesn't exist in ucrtbase.dll, regardless of the state of the __USE_MINGW_ANSI_STDIO define. Signed-off-by: Martin Storsjö--- mingw-w64-headers/crt/stdio.h | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h index d7208e9..dee984a 100644 --- a/mingw-w64-headers/crt/stdio.h +++ b/mingw-w64-headers/crt/stdio.h @@ -809,12 +809,6 @@ int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_li __builtin_va_end(ap); return ret; } - - __mingw_ovr - int __cdecl _vscprintf(const char * __restrict__ _Format,va_list _ArgList) - { -return __stdio_common_vsprintf(UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR, NULL, 0, _Format, NULL, _ArgList); - } #ifdef __GNUC__ #pragma GCC diagnostic pop #endif @@ -864,10 +858,18 @@ int snprintf (char * __restrict__ __stream, size_t __n, const char * __restrict_ #ifdef __GNUC__ #pragma GCC diagnostic pop #endif -#endif +#endif /* __MSVCRT_VERSION__ >= 0x1400 */ +#endif /* __USE_MINGW_ANSI_STDIO */ +#if __MSVCRT_VERSION__ >= 0x1400 + __mingw_ovr + int __cdecl _vscprintf(const char * __restrict__ _Format,va_list _ArgList) + { +return __stdio_common_vsprintf(UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR, NULL, 0, _Format, NULL, _ArgList); + } +#else _CRTIMP int __cdecl _vscprintf(const char * __restrict__ _Format,va_list _ArgList); -#endif /* __MSVCRT_VERSION__ >= 0x1400 */ +#endif _CRTIMP int __cdecl _set_printf_count_output(int _Value); _CRTIMP int __cdecl _get_printf_count_output(void); -- 2.7.4 -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] [PATCH] stdio.h: Fixed misplaced #endif.
On Fri, 29 Sep 2017, Jacek Caban wrote: Please review. Signed-off-by: Jacek Caban--- mingw-w64-headers/crt/stdio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) This actually isn't correct for the cases when building with __MSVCRT_VERSION__ = 0x1400. I'll post another version that takes care of that, that should work for all combos of __MSVCRT_VERSION__ and __USE_MINGW_ANSI_STDIO. // Martin -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] [PATCH] stdio.h: Fixed misplaced #endif.
Please review. Signed-off-by: Jacek Caban--- mingw-w64-headers/crt/stdio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h index 34aae9ad..0d9cf1c7 100644 --- a/mingw-w64-headers/crt/stdio.h +++ b/mingw-w64-headers/crt/stdio.h @@ -880,10 +880,10 @@ int snprintf (char * __restrict__ __stream, size_t __n, const char * __restrict_ #ifdef __GNUC__ #pragma GCC diagnostic pop #endif -#endif +#endif /* __MSVCRT_VERSION__ >= 0x1400 */ +#endif /* __USE_MINGW_ANSI_STDIO */ _CRTIMP int __cdecl _vscprintf(const char * __restrict__ _Format,va_list _ArgList); -#endif /* __MSVCRT_VERSION__ >= 0x1400 */ _CRTIMP int __cdecl _set_printf_count_output(int _Value); _CRTIMP int __cdecl _get_printf_count_output(void); -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] [PATCHv3] crt: Avoid optimizing fprintf calls into fwrite in crt startup code
By avoiding turning fprintf(stderr,) into fwrite(stderr,) we can localize the compat wrapping for that to fprintf. Then we shouldn't ever need to worry about functions needing init_compat to be called before they're invoked by the constructor. This allows simplifying the ucrtbase_compat.c code quite significantly. Signed-off-by: Martin Storsjö--- Moved the -fno-builtin-fprintf to lib*_libmingw32_a_CFLAGS. --- mingw-w64-crt/Makefile.am | 4 mingw-w64-crt/crt/ucrtbase_compat.c | 42 + 2 files changed, 5 insertions(+), 41 deletions(-) diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index 8e8494e..eaa0080 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -596,6 +596,7 @@ lib32_liblargeint_a_CPPFLAGS=$(CPPFLAGS32) $(sysincludes) lib32_LIBRARIES += lib32/libmingw32.a lib32_libmingw32_a_CPPFLAGS=$(CPPFLAGS32) -D_SYSCRT=1 -DCRTDLL=1 $(extra_include) $(AM_CPPFLAGS) +lib32_libmingw32_a_CFLAGS=-fno-builtin-fprintf $(AM_CFLAGS) lib32_libmingw32_a_SOURCES = $(src_libmingw32) lib32_LIBRARIES += lib32/libmingwex.a @@ -903,6 +904,7 @@ lib64_liblargeint_a_CPPFLAGS=$(CPPFLAGS64) $(sysincludes) lib64_LIBRARIES += lib64/libmingw32.a lib64_libmingw32_a_CPPFLAGS=$(CPPFLAGS64) -D_SYSCRT=1 -DCRTDLL=1 $(extra_include) $(AM_CPPFLAGS) +lib64_libmingw32_a_CFLAGS=-fno-builtin-fprintf $(AM_CFLAGS) lib64_libmingw32_a_SOURCES = $(src_libmingw32) lib64_LIBRARIES += lib64/libmingwex.a @@ -1208,6 +1210,7 @@ libarm32_liblargeint_a_CPPFLAGS=$(CPPFLAGSARM32) $(sysincludes) libarm32_LIBRARIES += libarm32/libmingw32.a libarm32_libmingw32_a_CPPFLAGS=$(CPPFLAGSARM32) -D_SYSCRT=1 -DCRTDLL=1 $(extra_include) $(AM_CPPFLAGS) +libarm32_libmingw32_a_CFLAGS=-fno-builtin-fprintf $(AM_CFLAGS) libarm32_libmingw32_a_SOURCES = $(src_libmingw32) libarm32_LIBRARIES += libarm32/libmingwex.a @@ -1465,6 +1468,7 @@ libarm64_liblargeint_a_CPPFLAGS=$(CPPFLAGSARM64) $(sysincludes) libarm64_LIBRARIES += libarm64/libmingw32.a libarm64_libmingw32_a_CPPFLAGS=$(CPPFLAGSARM64) -D_SYSCRT=1 -DCRTDLL=1 $(extra_include) $(AM_CPPFLAGS) +libarm64_libmingw32_a_CFLAGS=-fno-builtin-fprintf $(AM_CFLAGS) libarm64_libmingw32_a_SOURCES = $(src_libmingw32) libarm64_LIBRARIES += libarm64/libmingwex.a diff --git a/mingw-w64-crt/crt/ucrtbase_compat.c b/mingw-w64-crt/crt/ucrtbase_compat.c index 3d0fdbb..ca5381a 100644 --- a/mingw-w64-crt/crt/ucrtbase_compat.c +++ b/mingw-w64-crt/crt/ucrtbase_compat.c @@ -151,9 +151,7 @@ char ** __MINGW_IMP_SYMBOL(_wcmdln); // to work properly with ucrtbase.dll. #define _EXIT_LOCK1 8 -static int compat_inited; static CRITICAL_SECTION exit_lock; -static size_t (*real_fwrite)(const void *restrict, size_t, size_t, FILE *restrict); static char * (*real_setlocale)(int, const char*); static wchar_t * (*real__wsetlocale)(int, const wchar_t*); static int local__mb_cur_max; @@ -164,14 +162,11 @@ static void __cdecl free_locks(void) DeleteCriticalSection(_lock); } -static void __cdecl init_compat(void) +static void __cdecl init_compat_dtor(void) { HANDLE ucrt; - if (compat_inited) -return; ucrt = GetModuleHandle("ucrtbase.dll"); - real_fwrite = (size_t (*)(const void *restrict, size_t, size_t, FILE *restrict)) GetProcAddress(ucrt, "fwrite"); real_setlocale = (char * (*)(int, const char*)) GetProcAddress(ucrt, "setlocale"); real__wsetlocale = (wchar_t * (*)(int, const wchar_t*)) GetProcAddress(ucrt, "_wsetlocale"); @@ -179,16 +174,6 @@ static void __cdecl init_compat(void) local__mb_cur_max = ___mb_cur_max_func(); - compat_inited = 1; -} - -static void __cdecl init_compat_dtor(void) -{ - init_compat(); - // atexit requires parts for this is inited at .CRT$XIAA, but we might need - // the compat init for fwrite (fprintf with a constant string) already in - // _pei386_runtime_relocator which for DLLs is run before the constructors - // in .CRT$XIAA. atexit(free_locks); } @@ -203,8 +188,6 @@ _CRTALLOC(".CRT$XID") _PVFV mingw_ucrtbase_compat_init = init_compat_dtor; char * __cdecl setlocale(int _Category, const char *_Locale) { char *ret; - if (!compat_inited) -init_compat(); ret = real_setlocale(_Category, _Locale); local__mb_cur_max = ___mb_cur_max_func(); return ret; @@ -213,8 +196,6 @@ char * __cdecl setlocale(int _Category, const char *_Locale) wchar_t * __cdecl _wsetlocale(int _Category, const wchar_t *_Locale) { wchar_t *ret; - if (!compat_inited) -init_compat(); ret = real__wsetlocale(_Category, _Locale); local__mb_cur_max = ___mb_cur_max_func(); return ret; @@ -256,8 +237,6 @@ FILE *__cdecl __iob_func(void) // files. int __cdecl vfprintf(FILE *ptr, const char *fmt, va_list ap) { - if (!compat_inited) -init_compat(); if (ptr != _iob[2]) abort(); return real_vfprintf(stderr, fmt, ap); @@ -267,8 +246,6 @@ int __cdecl fprintf(FILE *ptr, const char *fmt, ...) { va_list ap; int ret; - if
[Mingw-w64-public] [PATCH] crt: More strictly flag functions in the unified msvcrt.def.in
Now the output from the unified msvcrt.def.in should be almost identical to what it was before, except for some new *_dbg and __p_* functions. The functions that were included for 32 and 64 bit x86 in the unification were originally believed to be harmless, but some of them turned out to be function that we have compatibility fallbacks for, that were missed when libmsvcrt.a suddenly started. This broke compatibility with XP in some cases. Signed-off-by: Martin Storsjö--- mingw-w64-crt/lib-common/msvcrt.def.in | 229 - 1 file changed, 114 insertions(+), 115 deletions(-) diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in b/mingw-w64-crt/lib-common/msvcrt.def.in index 2b9af5c..bbf751e 100644 --- a/mingw-w64-crt/lib-common/msvcrt.def.in +++ b/mingw-w64-crt/lib-common/msvcrt.def.in @@ -97,7 +97,6 @@ $I10_OUTPUT ; void __cdecl operator delete[](void * __ptr64) ; GNU = __ZdaPv ??_V@YAXPEAX@Z -__uncaught_exception ; int (__cdecl*__cdecl _query_new_handler(void))(unsigned __int64) ; GNU = __Z18_query_new_handlerv ?_query_new_handler@@YAP6AH_K@ZXZ @@ -186,7 +185,6 @@ __ExceptionPtrDestroy __ExceptionPtrRethrow __ExceptionPtrSwap __ExceptionPtrToBool -__uncaught_exception ?_query_new_handler@@YAP6AHI@ZXZ ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z ?_set_new_mode@@YAHH@Z @@ -201,6 +199,7 @@ __uncaught_exception ?what@exception@@UBAPBDXZ #endif +#ifdef DEF_ARM32 _CrtCheckMemory _CrtDbgBreak _CrtDbgReport @@ -226,6 +225,7 @@ _CrtSetReportFile _CrtSetReportHook _CrtSetReportHook2 _CrtSetReportMode +#endif _CxxThrowException F_I386(_EH_prolog) _Getdays @@ -233,30 +233,30 @@ _Getmonths _Gettnames _HUGE DATA _Strftime -_W_Getdays -_W_Getmonths -_W_Gettnames -_Wcsftime +F_ARM_ANY(_W_Getdays) +F_ARM_ANY(_W_Getmonths) +F_ARM_ANY(_W_Gettnames) +F_ARM_ANY(_Wcsftime) _XcptFilter -__AdjustPointer -__C_specific_handler +F_ARM_ANY(__AdjustPointer) +F_NON_I386(__C_specific_handler) __CppXcptFilter -__CxxCallUnwindDtor -__CxxCallUnwindVecDtor -__CxxDetectRethrow -__CxxExceptionFilter +F_I386(__CxxCallUnwindDtor) +F_I386(__CxxCallUnwindVecDtor) +F_I386(__CxxDetectRethrow) +F_I386(__CxxExceptionFilter) __CxxFrameHandler -__CxxFrameHandler3 +F_ARM_ANY(__CxxFrameHandler3) F_I386(__CxxLongjmpUnwind) -__CxxQueryExceptionSize -__CxxRegisterExceptionObject -__CxxUnregisterExceptionObject +F_I386(__CxxQueryExceptionSize) +F_I386(__CxxRegisterExceptionObject) +F_I386(__CxxUnregisterExceptionObject) __DestructExceptionObject __RTCastToVoid __RTDynamicCast __RTtypeid __STRINGTOLD -___lc_codepage_func +F_NON_I386(___lc_codepage_func) ___lc_collate_cp_func ___lc_handle_func ___mb_cur_max_func @@ -272,10 +272,10 @@ __crtGetLocaleInfoW __crtGetStringTypeW __crtLCMapStringA __crtLCMapStringW -__daylight +F_ARM_ANY(__daylight) __dllonexit __doserrno -__dstbias +F_ARM_ANY(__dstbias) __fpecode __getmainargs F_X86_ANY(__initenv DATA) @@ -283,10 +283,9 @@ __iob_func __isascii __iscsym __iscsymf -__lc_clike +F_I386(__lc_clike) __lc_codepage DATA __lc_collate_cp DATA -__jump_unwind __lc_handle DATA __lconv_init __mb_cur_max DATA @@ -323,12 +322,12 @@ __pctype_func __pioinfo DATA __pwctype_func __pxcptinfoptrs -__security_error_handler +F_I386(__security_error_handler) __set_app_type -__set_buffer_overrun_handler +F_I386(__set_buffer_overrun_handler) __setlc_active DATA __setusermatherr -__strncnt +F_ARM_ANY(__strncnt) __threadhandle __threadid __toascii @@ -338,12 +337,12 @@ __unDNameEx __unguarded_readlc_active DATA __wargv DATA __wcserror -__wcserror_s -__wcsncnt +F_NON_I386(__wcserror_s) +F_ARM_ANY(__wcsncnt) __wgetmainargs F_X86_ANY(__winitenv DATA) -_abnormal_termination -_abs64 +F_I386(_abnormal_termination) +F_NON_I386(_abs64) _access ; _access_s Replaced by emu _acmdln DATA @@ -385,7 +384,7 @@ _atoi64_l _atoi_l _atol_l _atoldbl -_atoldbl_l +F_NON_I386(_atoldbl_l) _beep _beginthread _beginthreadex @@ -401,13 +400,13 @@ _cgetws _chdir _chdrive _chgsign -_chgsignf +F_NON_I386(_chgsignf) _chmod -_chkesp +F_I386(_chkesp) _chsize ; _chsize_s replaced by emu -_chvalidator -_chvalidator_l +F_ARM_ANY(_chvalidator) +F_ARM_ANY(_chvalidator_l) _clearfp _close _commit @@ -416,7 +415,7 @@ _control87 _controlfp ; _controlfp_s replaced by emu _copysign -_copysignf +F_NON_I386(_copysignf) _cprintf _cprintf_l _cprintf_p @@ -425,21 +424,22 @@ _cprintf_p_l ; _cprintf_s_l likewise. _cputs _cputws -_CRT_RTC_INIT +F_I386(_CRT_RTC_INIT) _creat _create_locale -_crtAssertBusy -_crtBreakAlloc -_crtDbgFlag +F_ARM32(_crtAssertBusy) +F_ARM32(_crtBreakAlloc) +F_ARM32(_crtDbgFlag) _cscanf _cscanf_l _cscanf_s _cscanf_s_l -_ctime32 +F_ARM_ANY(_ctime32) +F_I386(_ctime32 == ctime) ; _ctime32_s replaced by emu _ctime64 ; _ctime64_s replaced by emu -_ctypea DATA +_ctype F_I386(DATA) _cwait _cwprintf _cwprintf_l @@ -452,9 +452,9 @@ _cwscanf_l _cwscanf_s _cwscanf_s_l _dstbias DATA -_daylight DATA -_difftime32 -_difftime64