Re: [Mingw-w64-public] [PATCH] headers: Move some macros about deprecated functions from 'strsafe.h' into 'dontuse.h'
在 2024-02-29 01:14, Martin Storsjö 写道: It would be much more understandable, if the message would start with some context like this: ---8<--- WinSDK's strsafe.h also tries to discourage users from calling a bunch of its internal functions. This is done in two different ways; if DEPRECATE_SUPPORTED is defined (it gets defined by winnt.h), the functions are marked deprecated via e.g. "#pragma deprecated(StringLengthWorkerA)". If that isn't defined, those symbols are redefined to a missing name instead, e.g. "#define StringLengthWorkerA StringLengthWorkerA_instead_use_StringCchLengthA_or_StringCbLengthA" This contradicts my understanding: I don't think that `DEPRECATE_SUPPORTED` is a macro that is to be defined by users. Its conditional definition in 'winnt.h' is protected by `DECLSPEC_DEPRECATED`, and if a user defines it on themselves, they will get warnings about redefinition. As GCC doesn't support #pragma deprecated, our version doesn't use that, so we only redirect/rename uses of these functions if DEPRECATE_SUPPORTED isn't defined - to match the effect on the WinSDK headers (where the names are usable but gets warned about, if DEPRECATE_SUPPORTED is defined). ---8<--- That, IMO, is more understandable by people just looking at the patch in isolation, and/or looking at our headers. Alternatively, we could just skip adding this ifdef in this patch, as we don't have the alternative way of marking the deprecation - that would get the message across to the users even more clearly? There is a difference about these two approaches: `#pragma deprecated` effects warnings, while defining those names to non-exitent ones effects hard errors. Including 'dontuse.h' and getting hard errors might be expected, but including 'strsafe.h' and getting accidental hard errors is probably unwanted. However that's already how Microsoft headers behave. -- Best regards, LIU Hao OpenPGP_signature.asc Description: OpenPGP digital signature ___ 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] crt: Fix comments in msvcrt-common.def.in
On Wednesday 28 February 2024 23:24:25 Martin Storsjö wrote: > On Wed, 28 Feb 2024, Pali Rohár wrote: > > > All commented lines refers to non-underscore aliases for underscored > > variant of functions. Aliases for some reasons are not prevent, e.g. > > because some aliases are defined in other files (CRT_fp10.c and CRT_fp8.c). > > I don't understand what the second sentence here is saying, can you rephrase > it? Ok, I will try to explain it a bit more. ADD_UNDERSCORE is a macro which just adds a symbol alias. It does not export any new symbol. #define ADD_UNDERSCORE(symbol) symbol == _ ## symbol Symbol "fpreset" is already defined in CRT_fp10.c and CRT_fp8.c files as an alias to the "_fpreset" symbol. So ADD_UNDERSCORE(fpreset) should not be added into msvcrt-common.def.in because same job is already done by __attribute__((alias("_fpreset"))). > > --- > > mingw-w64-crt/def-include/msvcrt-common.def.in | 15 --- > > 1 file changed, 8 insertions(+), 7 deletions(-) > > > > > @@ -134,13 +135,13 @@ ADD_UNDERSCORE(y0) > > ADD_UNDERSCORE(y1) > > ADD_UNDERSCORE(yn) > > ADD_UNDERSCORE(chgsign) > > -;scalb > > +ADD_UNDERSCORE(scalb) > > This change here is, accidentally?, actually adding the alias even though it > was supposed to be commented out? > > // Martin Ah, it should not be there. My attempt was to cleanup comments without any functional change. But all those parenthesis, semicolons and pluses in diff make me hard to miss some accidental changes. ___ 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] crt: Define 32-bit time function aliases for all CRT libraries
On Wed, 28 Feb 2024, Pali Rohár wrote: Header file time.h already redirects function call gmtime() to _gmtime32(). So if object file compiled with time.h is linked with e.g. libmsvcrt40.a import library then it is needed to add redirection from _gmtime32 symbol to gmtime symbol into libmsvcrt40.a library to ensure that application would use gmtime symbol, because msvcrt40.dll does not provide _gmtime32. Same applies for all other 32-bit time symbols. --- mingw-w64-crt/lib32/crtdll.def.in | 14 +- mingw-w64-crt/lib32/msvcr70.def.in | 11 +++ mingw-w64-crt/lib32/msvcr71.def.in | 11 +++ mingw-w64-crt/lib32/msvcrt10.def.in | 9 + mingw-w64-crt/lib32/msvcrt20.def.in | 11 +++ mingw-w64-crt/lib32/msvcrt40.def.in | 11 +++ 6 files changed, 62 insertions(+), 5 deletions(-) LGTM // Martin ___ 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] crt: Fix comments in msvcrt-common.def.in
On Wed, 28 Feb 2024, Pali Rohár wrote: All commented lines refers to non-underscore aliases for underscored variant of functions. Aliases for some reasons are not prevent, e.g. because some aliases are defined in other files (CRT_fp10.c and CRT_fp8.c). I don't understand what the second sentence here is saying, can you rephrase it? --- mingw-w64-crt/def-include/msvcrt-common.def.in | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) @@ -134,13 +135,13 @@ ADD_UNDERSCORE(y0) ADD_UNDERSCORE(y1) ADD_UNDERSCORE(yn) ADD_UNDERSCORE(chgsign) -;scalb +ADD_UNDERSCORE(scalb) This change here is, accidentally?, actually adding the alias even though it was supposed to be commented out? // Martin ___ 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] crt: Update crtdll.def.in
On Wed, 28 Feb 2024, Pali Rohár wrote: * Include C++ mangled symbols * Include Windows NT 3.51+ symbols * Extend comment about different versions * Update list of symbols which do not have prototypes yet --- mingw-w64-crt/lib32/crtdll.def.in | 152 ++ 1 file changed, 29 insertions(+), 123 deletions(-) LGTM // Martin ___ 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] crt: Add link to CRT startup GNU LD bug
On Wed, 28 Feb 2024, Pali Rohár wrote: --- mingw-w64-crt/crt/crtdll.c | 2 +- mingw-w64-crt/crt/crtexe.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c index 0f08a1a50d78..88450ce9f74f 100644 --- a/mingw-w64-crt/crt/crtdll.c +++ b/mingw-w64-crt/crt/crtdll.c @@ -142,7 +142,7 @@ WINBOOL WINAPI DllMainCRTStartup (HANDLE, DWORD, LPVOID); int __mingw_init_ehandler (void); #endif -__attribute__((used)) /* required due to bug in gcc / ld */ +__attribute__((used)) /* required due to GNU LD bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30300 */ WINBOOL WINAPI DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) { LGTM // Martin ___ 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 1/2] crt: Do not export DllEntryPoint from def files
On Wed, 28 Feb 2024, Pali Rohár wrote: If application does not specify its own DllEntryPoint function then the default DllEntryPoint provided by libmingwex library should be used. And not from some random system DLL library. --- mingw-w64-crt/lib64/fxsdrv.def | 1 - mingw-w64-crt/lib64/wiaservc.def | 1 - 2 files changed, 2 deletions(-) These two patches LGTM. These symbols have annoyed me before, but this is a good example of why it's also harmful, not only annoying, to have these symbols around. (Separately, we probably should remove other similar exported symbols like DllRegisterServer as well? And from looking at your patch, e.g. pscript5, unidrv, look like something that should not be an import library at all. I've cleaned out a bunch of such def files before, but there's clearly many still left.) // Martin ___ 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 1/3] crt: Add non-inline variant of UCRT _scprintf, _snprintf and _snscanf functions
On Tuesday 09 May 2023 22:29:31 LIU Hao wrote: > Our conclusion is that, in order to reduce possible UCRT dependency, moving > inline definitions out of headers makes sense; but the other part, such as > duplication of functions, will not be accepted. Ok, so does it mean that the one change with title "crt: Add non-inline variant of UCRT _scprintf, _snprintf and _snscanf functions" is fine for you? Or do you need some modification of it? ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] [PATCH] crt: Define 32-bit time function aliases for all CRT libraries
Header file time.h already redirects function call gmtime() to _gmtime32(). So if object file compiled with time.h is linked with e.g. libmsvcrt40.a import library then it is needed to add redirection from _gmtime32 symbol to gmtime symbol into libmsvcrt40.a library to ensure that application would use gmtime symbol, because msvcrt40.dll does not provide _gmtime32. Same applies for all other 32-bit time symbols. --- mingw-w64-crt/lib32/crtdll.def.in | 14 +- mingw-w64-crt/lib32/msvcr70.def.in | 11 +++ mingw-w64-crt/lib32/msvcr71.def.in | 11 +++ mingw-w64-crt/lib32/msvcrt10.def.in | 9 + mingw-w64-crt/lib32/msvcrt20.def.in | 11 +++ mingw-w64-crt/lib32/msvcrt40.def.in | 11 +++ 6 files changed, 62 insertions(+), 5 deletions(-) diff --git a/mingw-w64-crt/lib32/crtdll.def.in b/mingw-w64-crt/lib32/crtdll.def.in index e388622a4351..e98d70d6d099 100644 --- a/mingw-w64-crt/lib32/crtdll.def.in +++ b/mingw-w64-crt/lib32/crtdll.def.in @@ -197,9 +197,11 @@ _fputwchar _fsopen _fstat _ftime +_ftime32 == _ftime _ftol _fullpath _futime +_futime32 == _futime _gcvt _get_osfhandle _getch @@ -406,6 +408,7 @@ _ungetch _unlink _unloaddll _utime +_utime32 == _utime _vsnprintf _vsnwprintf _wcsdup @@ -449,8 +452,9 @@ clock cos DATA cosh ctime DATA -;_ctime32 = ctime +_ctime32 == ctime difftime +_difftime32 == difftime div exit exp DATA @@ -486,7 +490,7 @@ getchar getenv gets gmtime DATA -;_gmtime32 = gmtime +_gmtime32 == gmtime is_wctype isalnum isalpha @@ -518,7 +522,7 @@ ldexp DATA ldiv localeconv localtime DATA -;_localtime32 = localtime +_localtime32 == localtime log log10 longjmp @@ -532,7 +536,7 @@ memcpy memmove memset mktime DATA -;_mktime32 = mktime +_mktime32 == mktime modf perror pow @@ -585,7 +589,7 @@ system tan tanh time DATA -;_time32 = time +_time32 == time tmpfile tmpnam tolower diff --git a/mingw-w64-crt/lib32/msvcr70.def.in b/mingw-w64-crt/lib32/msvcr70.def.in index 721dd7959868..e80d2b68a5bc 100644 --- a/mingw-w64-crt/lib32/msvcr70.def.in +++ b/mingw-w64-crt/lib32/msvcr70.def.in @@ -349,10 +349,12 @@ _fstat _fstat64 _fstati64 _ftime +_ftime32 == _ftime _ftime64 _ftol _fullpath _futime +_futime32 == _futime _futime64 _gcvt _get_osfhandle @@ -614,6 +616,7 @@ _unlink _unloaddll _unlock _utime +_utime32 == _utime _utime64 _vscprintf _vscwprintf @@ -640,6 +643,7 @@ _wcstoi64 _wcstoui64 _wcsupr _wctime +_wctime32 == _wctime _wctime64 _wctype DATA _wenviron DATA @@ -706,6 +710,7 @@ _wtoi64 _wtol _wunlink _wutime +_wutime32 == _wutime _wutime64 _y0 _y1 @@ -729,7 +734,9 @@ clock cos cosh ctime +_ctime32 == ctime difftime +_difftime32 == difftime div exit exp @@ -769,6 +776,7 @@ gets getwc getwchar gmtime +_gmtime32 == gmtime is_wctype isalnum isalpha @@ -800,6 +808,7 @@ ldexp ldiv localeconv localtime +_localtime32 == localtime log log10 longjmp @@ -813,6 +822,7 @@ memcpy memmove memset mktime +_mktime32 == mktime modf perror pow @@ -867,6 +877,7 @@ system tan tanh time +_time32 == time tmpfile tmpnam tolower diff --git a/mingw-w64-crt/lib32/msvcr71.def.in b/mingw-w64-crt/lib32/msvcr71.def.in index 7e120a22fc10..66c87d1dc654 100644 --- a/mingw-w64-crt/lib32/msvcr71.def.in +++ b/mingw-w64-crt/lib32/msvcr71.def.in @@ -342,10 +342,12 @@ _fstat _fstat64 _fstati64 _ftime +_ftime32 == _ftime _ftime64 _ftol _fullpath _futime +_futime32 == _futime _futime64 _gcvt _get_heap_handle @@ -609,6 +611,7 @@ _unlink _unloaddll _unlock _utime +_utime32 == _utime _utime64 _vscprintf _vscwprintf @@ -635,6 +638,7 @@ _wcstoi64 _wcstoui64 _wcsupr _wctime +_wctime32 == _wctime _wctime64 _wctype DATA _wenviron DATA @@ -701,6 +705,7 @@ _wtoi64 _wtol _wunlink _wutime +_wutime32 == _wutime _wutime64 _y0 _y1 @@ -724,7 +729,9 @@ clock cos cosh ctime +_ctime32 == ctime difftime +_difftime32 == difftime div exit exp @@ -764,6 +771,7 @@ gets getwc getwchar gmtime +_gmtime32 == gmtime is_wctype isalnum isalpha @@ -795,6 +803,7 @@ ldexp ldiv localeconv localtime +_localtime32 == localtime log log10 longjmp @@ -808,6 +817,7 @@ memcpy memmove memset mktime +_mktime32 == mktime modf perror pow @@ -862,6 +872,7 @@ system tan tanh time +_time32 == time tmpfile tmpnam tolower diff --git a/mingw-w64-crt/lib32/msvcrt10.def.in b/mingw-w64-crt/lib32/msvcrt10.def.in index 58c4a3673745..00c2ef017076 100644 --- a/mingw-w64-crt/lib32/msvcrt10.def.in +++ b/mingw-w64-crt/lib32/msvcrt10.def.in @@ -972,9 +972,11 @@ _fputwchar _fsopen _fstat _ftime +_ftime32 == _ftime _ftol _fullpath _futime +_futime32 == _futime _gcvt _get_osfhandle _getch @@ -1090,6 +1092,7 @@ _umask _ungetch _unlink _utime +_utime32 == _utime _vsnprintf _vsnwprintf _wcsdup @@ -1127,7 +1130,9 @@ clock cos cosh ctime +_ctime32 == ctime difftime +_difftime32 == difftime div exit exp @@ -1163,6 +1168,7 @@ getchar getenv gets gmtime +_gmtime32 == gmtime
[Mingw-w64-public] [PATCH] crt: Fix comments in msvcrt-common.def.in
All commented lines refers to non-underscore aliases for underscored variant of functions. Aliases for some reasons are not prevent, e.g. because some aliases are defined in other files (CRT_fp10.c and CRT_fp8.c). --- mingw-w64-crt/def-include/msvcrt-common.def.in | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mingw-w64-crt/def-include/msvcrt-common.def.in b/mingw-w64-crt/def-include/msvcrt-common.def.in index b68964db0dca..c9d92bf8911a 100644 --- a/mingw-w64-crt/def-include/msvcrt-common.def.in +++ b/mingw-w64-crt/def-include/msvcrt-common.def.in @@ -41,11 +41,12 @@ ADD_UNDERSCORE(fgetchar) ADD_UNDERSCORE(fgetwchar) ADD_UNDERSCORE(filelength) ADD_UNDERSCORE(fileno) -; fpreset) +; Alias fpreset is set in CRT_fp10.c and CRT_fp8.c. +; ADD_UNDERSCORE(fpreset) ADD_UNDERSCORE(fputchar) ADD_UNDERSCORE(fputwchar) -;fstat) -;ftime) +; ADD_UNDERSCORE(fstat) +; ADD_UNDERSCORE(ftime) ADD_UNDERSCORE(gcvt) ADD_UNDERSCORE(getch) ADD_UNDERSCORE(getche) @@ -90,7 +91,7 @@ ADD_UNDERSCORE(spawnv) ADD_UNDERSCORE(spawnve) ADD_UNDERSCORE(spawnvp) ADD_UNDERSCORE(spawnvpe) -;stat) +; ADD_UNDERSCORE(stat) #ifndef UCRTBASE ADD_UNDERSCORE(strcmpi) #endif @@ -134,13 +135,13 @@ ADD_UNDERSCORE(y0) ADD_UNDERSCORE(y1) ADD_UNDERSCORE(yn) ADD_UNDERSCORE(chgsign) -;scalb +ADD_UNDERSCORE(scalb) ADD_UNDERSCORE(finite) ADD_UNDERSCORE(fpclass) ; C99 functions -;cabs +; ADD_UNDERSCORE(cabs) ADD_UNDERSCORE(hypot) -;logb +; ADD_UNDERSCORE(logb) ADD_UNDERSCORE(nextafter) #ifndef UCRTBASE -- 2.20.1 ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] [PATCH] crt: Update crtdll.def.in
* Include C++ mangled symbols * Include Windows NT 3.51+ symbols * Extend comment about different versions * Update list of symbols which do not have prototypes yet --- mingw-w64-crt/lib32/crtdll.def.in | 152 ++ 1 file changed, 29 insertions(+), 123 deletions(-) diff --git a/mingw-w64-crt/lib32/crtdll.def.in b/mingw-w64-crt/lib32/crtdll.def.in index d8b5bd82114e..e388622a4351 100644 --- a/mingw-w64-crt/lib32/crtdll.def.in +++ b/mingw-w64-crt/lib32/crtdll.def.in @@ -4,22 +4,27 @@ ;* This file is part of the mingw-runtime package. ;* No warranty is given; refer to the file DISCLAIMER.PD within the package. ; -; Exports from crtdll.dll from Windows 95 SYSTEM directory. Hopefully this -; should also work with the crtdll provided with Windows NT. +; Exports from crtdll.dll from Windows 95 SYSTEM directory. Matches also +; crtdll.dll provided with Windows 98, Windows Me and Windows NT 3.50. +; It is compatible also with new Windows NT versions (e.g. Windows 10). +; +; Windows NT 3.1 misses following symbols: +; _set_new_handler __dllonexit _heapchk _heapmin _heapset _heapwalk _ismb* +; _mb* (except _mbstrlen) _strdec _strinc _strncnt _strnextc _strninc _strspnp +; _wtoi _wtol +; +; Win32s 1.30c on Windows 3.1 misses following symbols: +; __argc_dll __argv_dll _environ_dll _pgmptr_dll +; +; Win32s on Windows 3.1, Windows NT 3.51 and new Windows NT versions contains +; additional symbols defined at the end of file. ; ; NOTE: The crtdll is OBSOLETE and msvcrt should be used instead. The msvcrt ; is available for free download from Microsoft Corporation and will work on ; Windows 95. Support for the crtdll is deprecated and this file may be ; deleted in future versions. ; -; These three functions appear to be name mangled in some way, so GCC is -; probably not going to be able to use them in any case. -; -;??2@YAPAXI@Z -;??3@YAXPAX@Z -;?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z -; -; These are functions for which I have not yet written prototypes or +; These are symbols for which I have not yet written prototypes or ; otherwise set up (they are still included below though unlike those ; first three). ; @@ -40,143 +45,38 @@ ;_CItan ;_CItanh ;__dllonexit -;__mb_cur_max_dll -;__threadhandle -;__threadid -;_abnormal_termination ;_acmdln_dll ;_aexit_rtn_dll ;_amsg_exit -;_commit ;_commode_dll ;_cpumode_dll ;_ctype -;_expand -;_fcloseall -;_filbuf ;_fileinfo_dll -;_flsbuf -;_flushall ;_fmode_dll -;_fpieee_flt -;_fsopen ;_ftol -;_getdiskfree -;_getdllprocaddr -;_getdrive -;_getdrives -;_getsystime ;_initterm -;_ismbbalnum -;_ismbbalpha -;_ismbbgraph -;_ismbbkalnum -;_ismbbkana -;_ismbbkpunct -;_ismbblead -;_ismbbprint -;_ismbbpunct -;_ismbbtrail -;_ismbcalpha -;_ismbcdigit -;_ismbchira -;_ismbckata -;_ismbcl0 -;_ismbcl1 -;_ismbcl2 -;_ismbclegal -;_ismbclower -;_ismbcprint -;_ismbcspace -;_ismbcsymbol -;_ismbcupper -;_ismbslead -;_ismbstrail -;_lfind -;_loaddll -;_lrotl -;_lrotr -;_lsearch -;_makepath -;_matherr -;_mbbtombc -;_mbbtype -;_mbccpy -;_mbcjistojms -;_mbcjmstojis -;_mbclen -;_mbctohira -;_mbctokata -;_mbctolower -;_mbctombb -;_mbctoupper -;_mbctype -;_mbsbtype -;_mbscat -;_mbscmp -;_mbscpy -;_mbscspn -;_mbsdec -;_mbsdup -;_mbsicmp -;_mbsinc -;_mbslen -;_mbslwr -;_mbsnbcat -;_mbsnbcmp -;_mbsnbcnt -;_mbsnbcpy -;_mbsnbicmp -;_mbsnbset -;_mbsnccnt -;_mbsncmp -;_mbsncpy -;_mbsnextc -;_mbsnicmp -;_mbsninc -;_mbsnset -;_mbspbrk -;_mbsrchr -;_mbsrev -;_mbsset -;_mbsspn -;_mbsspnp -;_mbsstr -;_mbstrlen -;_mbsupr -;_onexit ;_osversion_dll -;_pctype_dll ;_purecall -;_pwctype_dll -;_rmtmp -;_rotl -;_rotr -;_setsystime -;_snprintf -;_snwprintf -;_splitpath -;_strdate ;_strdec ;_strinc ;_strncnt ;_strnextc ;_strninc ;_strspnp -;_strtime -;_tempnam -;_ultoa -;_unloaddll -;_vsnprintf -;_vsnwprintf -;_wtoi -;_wtol ; LIBRARY "crtdll.dll" EXPORTS #include "msvcrt-common.def.in" +; crtdll.dll contains 3 mangled C++ symbols +; void *__cdecl operator new(unsigned int) +??2@YAPAXI@Z +; void __cdecl operator delete(void *) +??3@YAXPAX@Z +; int(__cdecl *)(unsigned int)__cdecl _set_new_handler(int(__cdecl *)(unsigned int)) +?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z + _CIacos _CIasin _CIatan @@ -724,3 +624,9 @@ wcsxfrm wctomb wprintf wscanf + +; crtdll.dll from Win32s (Windows 3.1) and crtdll.dll on Windows NT 3.51 (and new) +; contains 3 additional symbols which are not available in the Windows 95, 98 or ME. +_itow +_ltow
[Mingw-w64-public] [PATCH] crt: Add link to CRT startup GNU LD bug
--- mingw-w64-crt/crt/crtdll.c | 2 +- mingw-w64-crt/crt/crtexe.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c index 0f08a1a50d78..88450ce9f74f 100644 --- a/mingw-w64-crt/crt/crtdll.c +++ b/mingw-w64-crt/crt/crtdll.c @@ -142,7 +142,7 @@ WINBOOL WINAPI DllMainCRTStartup (HANDLE, DWORD, LPVOID); int __mingw_init_ehandler (void); #endif -__attribute__((used)) /* required due to bug in gcc / ld */ +__attribute__((used)) /* required due to GNU LD bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30300 */ WINBOOL WINAPI DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) { diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c index 1ca9815efe92..9d512687862b 100644 --- a/mingw-w64-crt/crt/crtexe.c +++ b/mingw-w64-crt/crt/crtexe.c @@ -146,7 +146,7 @@ static int __tmainCRTStartup (void); int WinMainCRTStartup (void); -__attribute__((used)) /* required due to bug in gcc / ld */ +__attribute__((used)) /* required due to GNU LD bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30300 */ int WinMainCRTStartup (void) { int ret = 255; @@ -177,7 +177,7 @@ int mainCRTStartup (void); int __mingw_init_ehandler (void); #endif -__attribute__((used)) /* required due to bug in gcc / ld */ +__attribute__((used)) /* required due to GNU LD bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30300 */ int mainCRTStartup (void) { int ret = 255; -- 2.20.1 ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] [PATCH 1/2] crt: Do not export DllEntryPoint from def files
If application does not specify its own DllEntryPoint function then the default DllEntryPoint provided by libmingwex library should be used. And not from some random system DLL library. --- mingw-w64-crt/lib64/fxsdrv.def | 1 - mingw-w64-crt/lib64/wiaservc.def | 1 - 2 files changed, 2 deletions(-) diff --git a/mingw-w64-crt/lib64/fxsdrv.def b/mingw-w64-crt/lib64/fxsdrv.def index 23a1e6d8263c..801bc847a754 100644 --- a/mingw-w64-crt/lib64/fxsdrv.def +++ b/mingw-w64-crt/lib64/fxsdrv.def @@ -6,7 +6,6 @@ ; LIBRARY FxsDrv.dll EXPORTS -DllEntryPoint DrvDisableDriver DrvEnableDriver DrvQueryDriverInfo diff --git a/mingw-w64-crt/lib64/wiaservc.def b/mingw-w64-crt/lib64/wiaservc.def index af756087a279..7d3334d82448 100644 --- a/mingw-w64-crt/lib64/wiaservc.def +++ b/mingw-w64-crt/lib64/wiaservc.def @@ -32,7 +32,6 @@ ServiceMain ; public: void __cdecl BUFFER_CHAIN_ITEM::SetUsed(unsigned long) __ptr64 ?SetUsed@BUFFER_CHAIN_ITEM@@QEAAXK@Z SvchostPushServiceGlobals -DllEntryPoint DllRegisterServer DllUnregisterServer wiasCreateChildAppItem -- 2.20.1 ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] [PATCH 2/2] crt: Do not export DllMain from def files
Trying to use or link DllMain symbol from some random system DLL library is in most cases a mistake. So hide all DllMain definitions from all def files. --- mingw-w64-crt/lib-common/acledit.def | 1 - mingw-w64-crt/lib-common/htui.def | 1 - mingw-w64-crt/lib-common/keymgr.def | 1 - mingw-w64-crt/lib-common/photowiz.def | 1 - mingw-w64-crt/lib-common/prntvpt.def | 1 - mingw-w64-crt/lib32/davclnt.def | 1 - mingw-w64-crt/lib32/msoledbsql.def| 1 - mingw-w64-crt/lib32/p2p.def | 1 - mingw-w64-crt/lib32/p2pcollab.def | 1 - mingw-w64-crt/lib32/prntvpt.def | 1 - mingw-w64-crt/lib32/spoolss.def | 1 - mingw-w64-crt/lib64/PS5UI.def | 1 - mingw-w64-crt/lib64/PSCRIPT5.def | 1 - mingw-w64-crt/lib64/UNIDRV.def| 1 - mingw-w64-crt/lib64/UNIDRVUI.def | 1 - mingw-w64-crt/lib64/admparse.def | 1 - mingw-w64-crt/lib64/dmconfig.def | 1 - mingw-w64-crt/lib64/exstrace.def | 1 - mingw-w64-crt/lib64/fldrclnr.def | 1 - mingw-w64-crt/lib64/fxsst.def | 1 - mingw-w64-crt/lib64/gpkcsp.def| 1 - mingw-w64-crt/lib64/guitrn.def| 1 - mingw-w64-crt/lib64/hnetwiz.def | 1 - mingw-w64-crt/lib64/ieencode.def | 1 - mingw-w64-crt/lib64/iisrtl.def| 1 - mingw-w64-crt/lib64/imeshare.def | 1 - mingw-w64-crt/lib64/imjpcus.def | 1 - mingw-w64-crt/lib64/imjputyc.def | 1 - mingw-w64-crt/lib64/iyuv_32.def | 1 - mingw-w64-crt/lib64/localspl.def | 1 - mingw-w64-crt/lib64/log.def | 1 - mingw-w64-crt/lib64/migism.def| 1 - mingw-w64-crt/lib64/msdart.def| 1 - mingw-w64-crt/lib64/msoledbsql.def| 1 - mingw-w64-crt/lib64/mtxclu.def| 1 - mingw-w64-crt/lib64/netplwiz.def | 1 - mingw-w64-crt/lib64/ntlanman.def | 1 - mingw-w64-crt/lib64/ntlanui.def | 1 - mingw-w64-crt/lib64/oledb32.def | 1 - mingw-w64-crt/lib64/p2pcollab.def | 1 - mingw-w64-crt/lib64/printui.def | 1 - mingw-w64-crt/lib64/profmap.def | 1 - mingw-w64-crt/lib64/script.def| 1 - mingw-w64-crt/lib64/spoolss.def | 1 - mingw-w64-crt/lib64/sqlxmlx.def | 1 - mingw-w64-crt/lib64/srrstr.def| 1 - mingw-w64-crt/lib64/strmfilt.def | 1 - mingw-w64-crt/lib64/sysmod.def| 1 - mingw-w64-crt/lib64/vdsutil.def | 1 - mingw-w64-crt/lib64/w3tp.def | 1 - mingw-w64-crt/lib64/xinput1_1.def | 1 - mingw-w64-crt/lib64/xinput1_2.def | 1 - mingw-w64-crt/lib64/xinput1_3.def | 1 - mingw-w64-crt/libce/toolhelp.def | 1 - 54 files changed, 54 deletions(-) diff --git a/mingw-w64-crt/lib-common/acledit.def b/mingw-w64-crt/lib-common/acledit.def index da55b740076f..5d29e73a5dcf 100644 --- a/mingw-w64-crt/lib-common/acledit.def +++ b/mingw-w64-crt/lib-common/acledit.def @@ -9,7 +9,6 @@ EXPORTS EditAuditInfo EditOwnerInfo EditPermissionInfo -DllMain FMExtensionProcW SedDiscretionaryAclEditor SedSystemAclEditor diff --git a/mingw-w64-crt/lib-common/htui.def b/mingw-w64-crt/lib-common/htui.def index a778a275bd0e..24c3f057dd38 100644 --- a/mingw-w64-crt/lib-common/htui.def +++ b/mingw-w64-crt/lib-common/htui.def @@ -6,7 +6,6 @@ ; LIBRARY htUI.dll EXPORTS -DllMain HTUI_ColorAdjustment HTUI_ColorAdjustmentA HTUI_ColorAdjustmentW diff --git a/mingw-w64-crt/lib-common/keymgr.def b/mingw-w64-crt/lib-common/keymgr.def index db865ef3e2db..039d846003c5 100644 --- a/mingw-w64-crt/lib-common/keymgr.def +++ b/mingw-w64-crt/lib-common/keymgr.def @@ -7,7 +7,6 @@ LIBRARY KEYMGR.dll EXPORTS CPlApplet -DllMain KRShowKeyMgr PRShowRestoreFromMsginaW PRShowRestoreWizardExW diff --git a/mingw-w64-crt/lib-common/photowiz.def b/mingw-w64-crt/lib-common/photowiz.def index 057a165138dd..3298eea87ae5 100644 --- a/mingw-w64-crt/lib-common/photowiz.def +++ b/mingw-w64-crt/lib-common/photowiz.def @@ -10,6 +10,5 @@ UsePPWForPrintTo DllCanUnloadNow DllGetClassObject DllInstall -DllMain DllRegisterServer DllUnregisterServer diff --git a/mingw-w64-crt/lib-common/prntvpt.def b/mingw-w64-crt/lib-common/prntvpt.def index 5a2d51289752..efaa3a010020 100644 --- a/mingw-w64-crt/lib-common/prntvpt.def +++ b/mingw-w64-crt/lib-common/prntvpt.def @@ -18,7 +18,6 @@ ConvertPrintTicketToDevModeThunk ConvertPrintTicketToDevModeThunk2 DllCanUnloadNow DllGetClassObject -DllMain DllRegisterServer DllUnregisterServer GetDeviceDefaultPrintTicketThunk diff --git a/mingw-w64-crt/lib32/davclnt.def b/mingw-w64-crt/lib32/davclnt.def index 5dcc9f8e6a35..1c4a516e2626 100644 --- a/mingw-w64-crt/lib32/davclnt.def +++ b/mingw-w64-crt/lib32/davclnt.def @@ -14,7 +14,6 @@ DavRegisterAuthCallback@8 DavUnregisterAuthCallback@4 DllCanUnloadNow@0 DllGetClassObject@12 -DllMain@12 NPAddConnection3@20 NPAddConnection@12 NPCancelConnection@8 diff --git a/mingw-w64-crt/lib32/msoledbsql.def b/mingw-w64-crt/lib32/msoledbsql.def index fbea877100a0..89fc4cb45816 100644 --- a/mingw-w64-crt/lib32/msoledbsql.def +++
Re: [Mingw-w64-public] [PATCH] headers: Move some macros about deprecated functions from 'strsafe.h' into 'dontuse.h'
On Wed, 28 Feb 2024, LIU Hao wrote: Attached is the updated patch. Ok, so let's see... because the semicolon in the macro `lstrcpyA` affects not only invocations, but also declarations. Those semicolons have been removed since Windows SDK 8.0, so we remove them as well. This allows including 'strsafe.h' before 'windows.h'. Right, so this is the main fix of the patch - remove semicolons, which avoids breaking winnt.h if strsafe.h is included before that. There is an unsolved issue about `DEPRECATE_SUPPORTED`: It's a macro that is to be defined by 'winnt.h', so the order of inclusion matters: All the talk about DEPRECATE_SUPPORTED is almost indecipherable in this commit message, if one just looks at our headers and/or this patch - only after looking at the WinSDK headers, I see what you're saying. It would be much more understandable, if the message would start with some context like this: ---8<--- WinSDK's strsafe.h also tries to discourage users from calling a bunch of its internal functions. This is done in two different ways; if DEPRECATE_SUPPORTED is defined (it gets defined by winnt.h), the functions are marked deprecated via e.g. "#pragma deprecated(StringLengthWorkerA)". If that isn't defined, those symbols are redefined to a missing name instead, e.g. "#define StringLengthWorkerA StringLengthWorkerA_instead_use_StringCchLengthA_or_StringCbLengthA" As GCC doesn't support #pragma deprecated, our version doesn't use that, so we only redirect/rename uses of these functions if DEPRECATE_SUPPORTED isn't defined - to match the effect on the WinSDK headers (where the names are usable but gets warned about, if DEPRECATE_SUPPORTED is defined). ---8<--- That, IMO, is more understandable by people just looking at the patch in isolation, and/or looking at our headers. Alternatively, we could just skip adding this ifdef in this patch, as we don't have the alternative way of marking the deprecation - that would get the message across to the users even more clearly? // Martin ___ 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] headers: Move some macros about deprecated functions from 'strsafe.h' into 'dontuse.h'
在 2024-02-28 06:01, Martin Storsjö 写道: Can you mention in the commit message, what used to break if strsafe.h was included befoe windows.h? The commit message explains that we're moveing a bunch of macros from strsafe.h into dontuse.h, but in the diff, I'm also seeing a bunch of other minor changes - the macros for e.g. StringCopyWorkerA have lost their unnecessary trailing semicolons; can we get that change in a separate commit for clarity? And I see a new "#ifndef DEPRECATE_SUPPORTED" wrapped around that as well, which also seems to not be explained in the commit message? Attached is the updated patch. There is an unsolved issue about `DEPRECATE_SUPPORTED`: It's a macro that is to be defined by 'winnt.h', so the order of inclusion matters: $ gcc -xc - && echo $? #include #include int main(void) { char t[10]; StringCopyWorkerA(t, sizeof(t), "meow"); } ^Z 0 $ gcc -xc - && echo $? #include #include int main(void) { char t[10]; StringCopyWorkerA(t, sizeof(t), "meow"); } ^Z C:\msys64\tmp\cc1wARDe.o::(.text+0x21): undefined reference to `StringCopyWorkerA_instead_use_StringCchCopyA_or_StringCchCopyExA' collect2.exe: error: ld returned 1 exit status We may provide a local copy of the deprecated attribute in 'strsafe.h', but it would require another patch. -- Best regards, LIU Hao From 0c578c39c17b94af80dcc91b7ae16c46cda6fd37 Mon Sep 17 00:00:00 2001 From: LIU Hao Date: Wed, 28 Feb 2024 23:03:58 +0800 Subject: [PATCH] headers: Move some macros about deprecated functions from 'strsafe.h' into 'dontuse.h' Since Windows SDK 8.0, `STRSAFE_NO_DEPRECATE` no longer has an effect. It's still defined by some headers, but the check in 'strsafe.h' has been removed. Those macros that match POSIX names have been moved to 'dontuse.h', so we do the same. Previously, inclusion of before could cause errors like In file included from C:/msys64/mingw64/include/windows.h:70, from test.c:2: C:/msys64/mingw64/include/winbase.h:1499:37: error: expected identifier or '(' before 'LPSTR' 1499 | WINBASEAPI LPSTR WINAPI lstrcpyA (LPSTR lpString1, LPCSTR lpString2); | ^ because the semicolon in the macro `lstrcpyA` affects not only invocations, but also declarations. Those semicolons have been removed since Windows SDK 8.0, so we remove them as well. This allows including 'strsafe.h' before 'windows.h'. The effect of `DEPRECATE_SUPPORTED` is a bit complex: It is defined by 'winnt.h'. In Microsoft headers, it indicates that both `__declspec(deprecated)` and `#pragma deprecated` are supported. This macro controls whether those functions are deprecated via pragmas, or with macros. If 'strsafe.h' is include AFTER or without 'windows.h' and 'winnt.h', then `DEPRECATE_SUPPORTED` is not defined, and a user may get ccYRG0RL.o:test.c:(.text+0x1c): undefined reference to `strcpy_instead_use_StringCbCopyA_or_StringCchCopyA' collect2.exe: error: ld returned 1 exit status Unfortunately, GCC does not support `#pragma deprecated`, so there is no warning if `DEPRECATE_SUPPORTED` is defined (like in 'pathcch.h'). This may be improved in the future. Reported-by: Julian Waters Signed-off-by: LIU Hao --- mingw-w64-headers/include/dontuse.h | 161 mingw-w64-headers/include/strsafe.h | 187 +++- 2 files changed, 181 insertions(+), 167 deletions(-) create mode 100644 mingw-w64-headers/include/dontuse.h diff --git a/mingw-w64-headers/include/dontuse.h b/mingw-w64-headers/include/dontuse.h new file mode 100644 index 0..ac6497c95 --- /dev/null +++ b/mingw-w64-headers/include/dontuse.h @@ -0,0 +1,161 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ +#ifndef _DONTUSE_H_INCLUDED_ +#define _DONTUSE_H_INCLUDED_ + +#include + +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + +#undef strcpy +#define strcpy strcpy_instead_use_StringCbCopyA_or_StringCchCopyA + +#undef wcscpy +#define wcscpy wcscpy_instead_use_StringCbCopyW_or_StringCchCopyW + +#undef strcat +#define strcat strcat_instead_use_StringCbCatA_or_StringCchCatA + +#undef wcscat +#define wcscat wcscat_instead_use_StringCbCatW_or_StringCchCatW + +#undef sprintf +#define sprintf sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA + +#undef swprintf +#define swprintf swprintf_instead_use_StringCbPrintfW_or_StringCchPrintfW + +#undef vsprintf +#define vsprintf vsprintf_instead_use_StringCbVPrintfA_or_StringCchVPrintfA + +#undef vswprintf +#define vswprintf vswprintf_instead_use_StringCbVPrintfW_or_StringCchVPrintfW + +#undef _snprintf +#define _snprintf _snprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA + +#undef _snwprintf +#define _snwprintf
Re: [Mingw-w64-public] [PATCH] include/tchar: Add more macros
在 2024-02-28 06:04, Martin Storsjö 写道: On Mon, 26 Feb 2024, LIU Hao wrote: This should match latest Windows SDK except for `strtold_l()` and `wcstold_l()`. The Microsoft implementations produce 64-bit numbers that do not match the GNU ABI, and we at the moment do not have locale-aware implementations. LGTM, thanks! Thanks. Pushed now. -- Best regards, LIU Hao OpenPGP_signature.asc Description: OpenPGP digital signature ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public