[Mingw-w64-public] [PATCH] crt: Add fallback _vscprintf_emu code for __ms_vsnprintf()

2021-12-26 Thread Pali Rohár
Original MSVC 6.0 msvcrt.dll library does not provide _vscprintf() function. Therefore usage of snprintf() with this DLL library cause application crash. Add simple fallback implementation of _vscprintf() just for __ms_vsnprintf() to allow usage of snprintf() function also when using original msvcr

[Mingw-w64-public] [PATCH] crt: De-duplicate _vscprintf/_vsnprintf code

2021-12-26 Thread Pali Rohár
Functions __ms_snprintf() and __ms_vsnprintf() contains same logic and code around _vscprintf() and _vsnprintf() wrappers. Remove duplicated code from __ms_snprintf() and redirects __ms_snprintf() to __ms_vsnprintf(). --- mingw-w64-crt/stdio/snprintf.c | 22 +- 1 file changed,

Re: [Mingw-w64-public] [PATCH] crt: Add fallback _vscprintf_emu code for __ms_vsnprintf()

2022-01-01 Thread Pali Rohár
On Wednesday 29 December 2021 22:35:08 LIU Hao wrote: > 在 2021-12-23 22:20, Pali Rohár 写道: > > Original MSVC 6.0 msvcrt.dll library does not provide _vscprintf() > > function. Therefore usage of snprintf() with this DLL library cause > > application crash. Add simple fallb

Re: [Mingw-w64-public] [PATCH] crt: Add fallback _vscprintf_emu code for __ms_vsnprintf()

2022-01-01 Thread Pali Rohár
On Friday 31 December 2021 00:30:37 Jacek Caban wrote: > On 12/29/21 16:52, Martin Storsjö wrote: > > On Wed, 29 Dec 2021, LIU Hao wrote: > > > > > 在 2021-12-23 22:20, Pali Rohár 写道: > > > > Original MSVC 6.0 msvcrt.dll library does not provide _vscprintf()

[Mingw-w64-public] [PATCH] crt: Fix libcrtdll.a import library

2022-01-02 Thread Pali Rohár
Import library libcrtdll.a (for crtdll.dll runtime library) compiled during mingw-w64 build process is currently broken and cannot be used for linking executable applications. Trying to do it results in following linker errors: /usr/bin/i686-w64-mingw32-ld: .../i686-w64-mingw32/lib/crt2.o: in f

Re: [Mingw-w64-public] [PATCH] crt: Add fallback _vscprintf_emu code for __ms_vsnprintf()

2022-01-13 Thread Pali Rohár
On Tuesday 11 January 2022 11:40:45 Martin Storsjö wrote: > On Mon, 10 Jan 2022, LIU Hao wrote: > > > 在 2022-01-01 05:54, Pali Rohár 写道: > > > > > > Well, if you want from me any improvements in this patch, I can do it. > > > Just let me know what is neede

[Mingw-w64-public] [PATCH 1/2] crt: Add fallback _vscprintf() implementation

2022-01-13 Thread Pali Rohár
Original MSVC 6.0 msvcrt.dll library does not provide _vscprintf() function. MinGW-w64 __ms_snprintf() and __ms_vsnprintf() implementations call _vscprintf() function. So include fallback _vscprintf() implementation into MinGW-w64 crt code to allow applications to use snprintf() with original MSVC

[Mingw-w64-public] [PATCH 2/2] crt: Add fallback _scprintf() implementation

2022-01-13 Thread Pali Rohár
Original MSVC 6.0 msvcrt.dll library does not provide _scprintf() function. Add fallback _scprintf() implementation like for _vscprintf(). --- mingw-w64-crt/Makefile.am | 1 + mingw-w64-crt/lib-common/msvcrt.def.in | 4 ++ mingw-w64-crt/misc/_scprintf.c | 52

Re: [Mingw-w64-public] [PATCH 1/2] crt: Add fallback _vscprintf() implementation

2022-01-13 Thread Pali Rohár
On Thursday 13 January 2022 23:22:10 Martin Storsjö wrote: > On Wed, 12 Jan 2022, Pali Rohár wrote: > > > Original MSVC 6.0 msvcrt.dll library does not provide _vscprintf() > > function. MinGW-w64 __ms_snprintf() and __ms_vsnprintf() implementations > > call _vscprint

Re: [Mingw-w64-public] [PATCH 1/2] crt: Add fallback _vscprintf() implementation

2022-01-14 Thread Pali Rohár
On Friday 14 January 2022 13:45:38 Martin Storsjö wrote: > On Fri, 14 Jan 2022, Pali Rohár wrote: > > > On Thursday 13 January 2022 23:22:10 Martin Storsjö wrote: > > > On Wed, 12 Jan 2022, Pali Rohár wrote: > > > > > > > Original MSVC 6.0 msvc

Re: [Mingw-w64-public] [PATCH 1/2] crt: Add fallback _vscprintf() implementation

2022-01-15 Thread Pali Rohár
On Friday 14 January 2022 01:36:10 Pali Rohár wrote: > On Thursday 13 January 2022 23:22:10 Martin Storsjö wrote: > > On Wed, 12 Jan 2022, Pali Rohár wrote: > > > > > Original MSVC 6.0 msvcrt.dll library does not provide _vscprintf() > > > function. MinGW-w64 _

[Mingw-w64-public] [PATCH] crt: Fix v*scanf functions

2022-01-16 Thread Pali Rohár
Currently v*scanf functions are broken and crash when are called with more than 30 arguments in va_list. This is because va_list v*scanf functions are redirected to variadic *scanf functions and this redirect implemented in scanf.S file has fixed limit for 30 arguments. Number of arguments for msv

Re: [Mingw-w64-public] [PATCH] crt: Fix v*scanf functions

2022-01-25 Thread Pali Rohár
On Monday 24 January 2022 13:41:27 Martin Storsjö wrote: > On Sun, 16 Jan 2022, Pali Rohár wrote: > > > Currently v*scanf functions are broken and crash when are called with more > > than 30 arguments in va_list. This is because va_list v*scanf functions are > > redir

Re: [Mingw-w64-public] [PATCH] crt: Fix v*scanf functions

2022-01-25 Thread Pali Rohár
On Wednesday 26 January 2022 00:23:49 LIU Hao wrote: > 在 2022-01-16 22:44, Pali Rohár 写道: > > diff --git a/mingw-w64-crt/stdio/scanf2-argcount-template.c > > b/mingw-w64-crt/stdio/scanf2-argcount-template.c > > new file mode 100644 > > index ..c07e11797c39

[Mingw-w64-public] [PATCH] crt: Move crtdll.mri from lib-common/ to lib32/

2022-02-06 Thread Pali Rohár
crtdll.mri is used only for building 32-bit version of libcrtdll.a library. --- mingw-w64-crt/Makefile.am | 2 +- mingw-w64-crt/{lib-common => lib32}/crtdll.mri | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename mingw-w64-crt/{lib-common => lib32}/crtdll.mri (100%) d

[Mingw-w64-public] [PATCH v2] crt: Fix libcrtdll.a import library

2022-02-06 Thread Pali Rohár
Import library libcrtdll.a (for crtdll.dll runtime library) compiled during mingw-w64 build process is currently broken and cannot be used for linking executable applications. Trying to do it results in following linker errors: /usr/bin/i686-w64-mingw32-ld: .../i686-w64-mingw32/lib/crt2.o: in f

[Mingw-w64-public] [PATCH v2] crt: Fix v*scanf functions

2022-02-06 Thread Pali Rohár
Currently v*scanf functions are broken and crash when are called with more than 30 arguments in va_list. This is because va_list v*scanf functions are redirected to variadic *scanf functions and this redirect implemented in scanf.S file has fixed limit for 30 arguments. Number of arguments for msv

[Mingw-w64-public] [PATCH] crt: Simplify building *crt*.o startup files

2022-02-06 Thread Pali Rohár
MinGW-w64 has same startup files for crtdll.dll and msvcrt.dll and defining -D__CRTDLL__ or -D__MSVCRT__ has no effect on built *crt*.o files, they are same. So build startup files only once and create other as copy from the first one. Also remove -D__CRTDLL__ and -D__MSVCRT__ as they are not used

[Mingw-w64-public] [PATCH] crt: Optimize __ms_vsnprintf() for LTO

2022-02-06 Thread Pali Rohár
Mark _vscprintf() and _scprintf() functions with attribute pure as their return value depends only on passed arguments. In function __ms_vsnprintf() check only for n==0 and move _vscprintf() call at the end of function. This allows LTO to optimize out _vscprintf() call from __ms_vsnprintf() functi

Re: [Mingw-w64-public] [PATCH] crt: Fix v*scanf functions

2022-02-06 Thread Pali Rohár
On Wednesday 26 January 2022 14:45:58 LIU Hao wrote: > 在 1/26/22 04:05, Pali Rohár 写道: > > > > Yes, this is truth. However amd64 asm code already reads more pointers > > from stack (when number of them is smaller then number of arguments > > needed to pass via registe

Re: [Mingw-w64-public] [PATCH] crt: Optimize __ms_vsnprintf() for LTO

2022-02-08 Thread Pali Rohár
On Tuesday 08 February 2022 11:22:12 Martin Storsjö wrote: > On Tue, 8 Feb 2022, LIU Hao wrote: > > > 在 2/8/22 16:33, Martin Storsjö 写道: > > > On Sun, 6 Feb 2022, Pali Rohár wrote: > > > > > > > Mark _vscprintf() and _scprintf() functions with attribute

Re: [Mingw-w64-public] [PATCH v2] crt: Fix v*scanf functions

2022-02-09 Thread Pali Rohár
On Tuesday 08 February 2022 11:25:43 Martin Storsjö wrote: > On Sun, 6 Feb 2022, Pali Rohár wrote: > > > Currently v*scanf functions are broken and crash when are called with more > > than 30 arguments in va_list. This is because va_list v*scanf functions are > > redir

[Mingw-w64-public] [PATCH 2/2] crt: Fix building lc_locale_func.c for libcrtdll_extra.a

2022-02-18 Thread Pali Rohár
Object files in archive libcrtdll_extra.a (which are linked into import library for crtdll.dll) cannot use msvcrt.h as it uses msvcrt.dll runtime library. So avoid using msvcrt.h and __mingw_get_msvcrt_handle() in crtdll.dll runtime and directly use "setlocale_codepage_hack" implementation. This

[Mingw-w64-public] [PATCH 1/2] crt: Add macro __LIBMSVCRT_OS__ for guarding msvcrt.dll

2022-02-18 Thread Pali Rohár
Currently macro __LIBMSVCRT__ is defined when building any libmsvcr*.a import library. But header file msvcrt.h contains inline function __mingw_get_msvcrt_handle() which should be used only from import library for runtime msvcrt.dll (and not for any other runtime msvcr*.dll) as code from that head

[Mingw-w64-public] [PATCH] crt: Add missing __cdecl signature to ucrt functions

2022-02-18 Thread Pali Rohár
When assigning function pointer to variable, both function and variable should have same signature. Fix it. --- mingw-w64-crt/stdio/ucrt__vscprintf.c | 2 +- mingw-w64-crt/stdio/ucrt_snprintf.c | 2 +- mingw-w64-crt/stdio/ucrt_vsnprintf.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)

[Mingw-w64-public] [PATCH] headers: stdio.h: Add _(v)scprintf optimization

2022-02-18 Thread Pali Rohár
Redirect (v)snprintf() call with n==0 arg directly to _(v)scprintf() call at compile time. With this change gcc can optimize out __ms_(v)snprintf() call even when MinGW-w64 runtime was not compiled with LTO. --- mingw-w64-headers/crt/stdio.h | 14 ++ 1 file changed, 10 insertions(+), 4

[Mingw-w64-public] [PATCH v2 1/2] crt: Add macro __LIBMSVCRT_OS__ for guarding msvcrt.dll

2022-03-05 Thread Pali Rohár
Currently macro __LIBMSVCRT__ is defined when building any libmsvcr*.a import library. But header file msvcrt.h contains inline function __mingw_get_msvcrt_handle() which should be used only from import library for runtime msvcrt.dll (and not for any other runtime msvcr*.dll) as code from that head

[Mingw-w64-public] [PATCH v2 2/2] crt: Fix building lc_locale_func.c for libcrtdll_extra.a

2022-03-05 Thread Pali Rohár
Object files in archive libcrtdll_extra.a (which are linked into import library for crtdll.dll) cannot use msvcrt.h as it tries to load symbols at runtime from msvcrt.dll using GetProcAddress(). So avoid using msvcrt.h and __mingw_get_msvcrt_handle() in crtdll.dll runtime and directly use "setloca

[Mingw-w64-public] [PATCH 2/3] headers: _mingw.h: Set __MSVCRT_VERSION__ to 0x00 for crtdll.dll builds

2022-03-05 Thread Pali Rohár
When gcc was compiled with crtdll config then it links binaries with -lcrtdll instead of -lmsvcrt and predefines macro __CRTDLL__. So when __MSVCRT_VERSION__ was not manually set and gcc is not going to use -lmsvcrt then set __MSVCRT_VERSION__ to 0x00 to indicate that msvcrt.dll is not used. ---

[Mingw-w64-public] [PATCH 1/3] crt: Add (v)snprintf() support for crtdll.dll builds

2022-03-05 Thread Pali Rohár
MinGW-w64 (v)snprintf() implementation uses windows functions _(v)snprintf() and _(v)scprintf(). Runtime library crtdll.dll provides only _(v)snprintf(), so include MinGW-w64 emulation of _(v)scprintf() functions into libcrtdll.a import library. As header file and __mingw_get_msvcrt_handle() func

[Mingw-w64-public] [PATCH 3/3] headers: inttypes.h: Do not define 64-bit modifiers for crtdll.dll builds

2022-03-05 Thread Pali Rohár
crtdll.dll runtime does not suppport 64-bit printf/scanf modifiers. So when targeting crtdll.dll runtime and not using MinGW-w64 stdio functions then do not define any 64-bit modifier in inttypes.h header file. crtdll.dll does not interpret %I64d modifier and does not read next argument from varia

[Mingw-w64-public] [PATCH 1/2] headers: stdio.h: Declare __format__ attribute for _(v)scprintf functions

2022-03-05 Thread Pali Rohár
--- mingw-w64-headers/crt/stdio.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h index d96f5c96fc65..dd0f324db2be 100644 --- a/mingw-w64-headers/crt/stdio.h +++ b/mingw-w64-headers/crt/stdio.h @@ -721,6 +721,7 @@ int vsnprintf (

[Mingw-w64-public] [PATCH 2/2] headers: stdio.h: Declare __format__ attribute for _snscanf function

2022-03-05 Thread Pali Rohár
--- mingw-w64-headers/crt/stdio.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h index dd0f324db2be..76fffa177b10 100644 --- a/mingw-w64-headers/crt/stdio.h +++ b/mingw-w64-headers/crt/stdio.h @@ -732,6 +732,7 @@ int vsnprintf (c

[Mingw-w64-public] [PATCH 3/7] crt: Move dummy __setusermatherr() function into misc/dummy__setusermatherr.c file.

2022-03-06 Thread Pali Rohár
It would be used also in followup changes. --- mingw-w64-crt/Makefile.am | 1 + mingw-w64-crt/crt/crtdll_compat.c | 5 - mingw-w64-crt/misc/dummy__setusermatherr.c | 11 +++ 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 mingw-w64-crt/

[Mingw-w64-public] [PATCH 2/7] crt: Move dummy stdio _lock() and _unlock() functions into stdio/mingw_dummy__lock.c file

2022-03-06 Thread Pali Rohár
It would be used also in followup changes. --- mingw-w64-crt/Makefile.am | 1 + mingw-w64-crt/crt/crtdll_compat.c | 6 -- mingw-w64-crt/stdio/mingw_dummy__lock.c | 12 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 mingw-w64-crt/stdio/m

[Mingw-w64-public] [PATCH 1/7] crt: Move implementation of __initenv and __winitenv to common file misc/__initenv.c

2022-03-06 Thread Pali Rohár
crtdll.dll and ucrt needs same implementation of __initenv and __winitenv symbols. Deduplicate code and move it into a new misc/__initenv.c file. --- mingw-w64-crt/Makefile.am | 2 ++ mingw-w64-crt/crt/crtdll_compat.c | 6 -- mingw-w64-crt/crt/ucrtbase_compat.c | 5 - mingw-

[Mingw-w64-public] [PATCH 0/7] crt: Build more msvcrt import libraries

2022-03-06 Thread Pali Rohár
2003 and it supports loadable plugins, then new plugin may be developed and compiled by mingw-w64 with linking to msvcr71.dll (Visual Studio 2003 CRT) via libmsvcr71.a import library, which is build by this patch series. Pali Rohár (7): crt: Move implementation of __initenv and __winitenv to

[Mingw-w64-public] [PATCH 4/7] crt: Build import library for msvcrt10.dll

2022-03-06 Thread Pali Rohár
This is CRT runtime library for Visual C++ 1.x (MSVC 8.00). It should be distributed as a part of the application which use it. msvcrt10.def file was generated from the original redistributable version of this library. --- mingw-w64-crt/Makefile.am| 25 +- mingw-w64-crt/lib32/msvcrt10.de

[Mingw-w64-public] [PATCH 7/7] crt: Build import library for msvcr70.dll and msvcr71.dll

2022-03-06 Thread Pali Rohár
These are CRT runtime libraries for Visual Studio 2002 and 2003. These libraries need to be installed separately via redistributable packages. --- mingw-w64-crt/Makefile.am | 22 +- mingw-w64-crt/lib32/msvcr70.def | 899 mingw-w64-crt/lib32/msvcr70.mri | 6

[Mingw-w64-public] [PATCH 6/7] crt: Build import library for msvcrt40.dll

2022-03-06 Thread Pali Rohár
This is CRT runtime library for Visual C++ 4.0 (MSVC 10.00) and 4.1 (10.10). It is present in every 32-bit x86 Windows as a system library. msvcrt40.def file was generated from the original redistributable version of Visual C++ 4.1 library. --- mingw-w64-crt/Makefile.am| 18 +- mingw-w6

[Mingw-w64-public] [PATCH 5/7] crt: Build import library for msvcrt20.dll

2022-03-06 Thread Pali Rohár
This is CRT runtime library for Visual C++ 2.0 (MSVC 9.00) and is present in every 32-bit x86 Windows as a system library. --- mingw-w64-crt/Makefile.am| 20 +- mingw-w64-crt/lib32/msvcrt20.def | 1570 ++ mingw-w64-crt/lib32/msvcrt20.mri |6 + 3 files chan

Re: [Mingw-w64-public] [PATCH 0/7] crt: Build more msvcrt import libraries

2022-03-10 Thread Pali Rohár
On Thursday 10 March 2022 15:01:20 Martin Storsjö wrote: > Hi, > > On Mon, 7 Mar 2022, Pali Rohár wrote: > > > There are more variants of msvcrt runtime libraries and mingw-w64 > > currently does not build import library for each variant. Some variants > > are ava

[Mingw-w64-public] [PATCH] include/wdm.h: Fix -Wsign-compare warning in RtlExtendedMagicDivide()

2022-03-12 Thread Pali Rohár
x86_64-w64-mingw32-gcc throws following -Wsign-compare warning when compiling 64-bit NT kernel drivers which include ddk/ntddk.h file: ddk/wdm.h: In function ‘RtlExtendedMagicDivide’: ddk/wdm.h:9531:32: warning: operand of ?: changes signedness from ‘long long int’ to ‘ULONG64’ {aka ‘long lon

Re: [Mingw-w64-public] [PATCH 0/7] crt: Build more msvcrt import libraries

2022-04-01 Thread Pali Rohár
On Thursday 10 March 2022 22:51:12 Pali Rohár wrote: > On Thursday 10 March 2022 15:01:20 Martin Storsjö wrote: > > Hi, > > > > On Mon, 7 Mar 2022, Pali Rohár wrote: > > > > > There are more variants of msvcrt runtime libraries and mingw-w64 > > > cur

[Mingw-w64-public] [PATCH] crt: crtdll_compat: Add missing __cdecl signature for __GetMainArgs()

2022-04-03 Thread Pali Rohár
--- mingw-w64-crt/crt/crtdll_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mingw-w64-crt/crt/crtdll_compat.c b/mingw-w64-crt/crt/crtdll_compat.c index 0f0b8d4820da..7ab3a82984e0 100644 --- a/mingw-w64-crt/crt/crtdll_compat.c +++ b/mingw-w64-crt/crt/crtdll_compat.c @

[Mingw-w64-public] [PATCH] headers: inttypes.h: Do not define 64-bit modifiers for msvcrt10.dll builds

2022-04-03 Thread Pali Rohár
Runtime library msvcrt10.dll like crtdll.dll does not provide support for 64-bit printf/scanf modifiers. So do not define them for msvcrt10.dll too. --- mingw-w64-headers/crt/inttypes.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mingw-w64-headers/crt/inttypes.h b/m

[Mingw-w64-public] [PATCH] headers: configure: Add more msvcrt versions into --with-default-msvcrt list

2022-04-03 Thread Pali Rohár
Import libraries for all these msvcrt versions are already as part of build process. --- mingw-w64-headers/configure.ac | 15 +++ 1 file changed, 15 insertions(+) diff --git a/mingw-w64-headers/configure.ac b/mingw-w64-headers/configure.ac index 1307538ef480..d82280cd7515 100644 ---

Re: [Mingw-w64-public] [PATCH] include/wdm.h: Fix -Wsign-compare warning in RtlExtendedMagicDivide()

2022-06-25 Thread Pali Rohár
On Saturday 12 March 2022 19:14:49 Biswapriyo Nath wrote: > Just curious. If you have compiled a kernel driver with mingw-w64, > would you like to provide the project link? I am eager to learn it. Yes, I successfully compiled NT kernel driver with mingw-w64. But due to lot of bugs in GCC and GNU

[Mingw-w64-public] [PATCH 1/3] crt: Add non-inline variant of UCRT _scprintf, _snprintf and _snscanf functions

2022-09-18 Thread Pali Rohár
--- mingw-w64-crt/Makefile.am| 3 +++ mingw-w64-crt/stdio/ucrt__scprintf.c | 21 + mingw-w64-crt/stdio/ucrt__snprintf.c | 21 + mingw-w64-crt/stdio/ucrt__snscanf.c | 21 + 4 files changed, 66 insertions(+) create mode 10064

[Mingw-w64-public] [PATCH 2/3] headers: stdio.h: Add inline variant of UCRT _vscprintf and _vsnprintf function

2022-09-18 Thread Pali Rohár
--- mingw-w64-headers/crt/stdio.h | 17 ++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h index 76fffa177b10..1cebce723527 100644 --- a/mingw-w64-headers/crt/stdio.h +++ b/mingw-w64-headers/crt/stdio.h @@

[Mingw-w64-public] [PATCH 3/3] headers: stdio.h: Move near UCRT inline functions into one #ifdef block

2022-09-18 Thread Pali Rohár
--- mingw-w64-headers/crt/stdio.h | 29 +++-- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h index 1cebce723527..45b21d2997fb 100644 --- a/mingw-w64-headers/crt/stdio.h +++ b/mingw-w64-headers/cr

[Mingw-w64-public] [PATCH] headers: Fix _SECIMP comment

2022-09-18 Thread Pali Rohár
#if condition does not contain _CRTBLD check --- mingw-w64-headers/crt/float.h| 2 +- mingw-w64-headers/crt/io.h | 2 +- mingw-w64-headers/crt/memory.h | 2 +- mingw-w64-headers/crt/sec_api/conio_s.h | 2 +- mingw-w64-headers/crt/sec_api/stdio_s.h | 2 +- ming

[Mingw-w64-public] [PATCH] crt: Fix _vscprintf() uninitialized compile warning

2022-09-18 Thread Pali Rohár
stdio/_vscprintf.c: In function ‘emu_vscprintf’: stdio/_vscprintf.c:47:8: warning: ‘ret’ may be used uninitialized in this function [-Wmaybe-uninitialized] if (ret < 0) { ^ --- mingw-w64-crt/stdio/_vscprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mingw-

Re: [Mingw-w64-public] [PATCH 1/3] crt: Add non-inline variant of UCRT _scprintf, _snprintf and _snscanf functions

2022-09-19 Thread Pali Rohár
On Monday 19 September 2022 15:33:45 Martin Storsjö wrote: > On Sat, 17 Sep 2022, Pali Rohár wrote: > > > --- > > mingw-w64-crt/Makefile.am| 3 +++ > > mingw-w64-crt/stdio/ucrt__scprintf.c | 21 + > > mingw-w64-c

Re: [Mingw-w64-public] [PATCH 1/3] crt: Add non-inline variant of UCRT _scprintf, _snprintf and _snscanf functions

2022-09-20 Thread Pali Rohár
On Monday 19 September 2022 16:50:33 Martin Storsjö wrote: > On Mon, 19 Sep 2022, Pali Rohár wrote: > > > On Monday 19 September 2022 15:33:45 Martin Storsjö wrote: > > > On Sat, 17 Sep 2022, Pali Rohár wrote: > > > > > > > --- > > > > mingw

[Mingw-w64-public] [RFC PATCH] headers: Simplify _HUGE definition

2022-10-08 Thread Pali Rohár
_HUGE global variable is available and exported from crtdll and msvcrt libraries. So declare it explicitly via _CRTIMP as global variable and not via __MINGW_IMP_SYMBOL pointer. --- I'm really not sure what was the reason to define _HUGE via macro __MINGW_IMP_SYMBOL poinster. So maybe there is a re

Re: [Mingw-w64-public] [RFC PATCH] headers: Simplify _HUGE definition

2022-10-08 Thread Pali Rohár
On Saturday 08 October 2022 20:07:56 LIU Hao wrote: > 在 2022/10/8 19:10, Pali Rohár 写道: > > _HUGE global variable is available and exported from crtdll and msvcrt > > libraries. So declare it explicitly via _CRTIMP as global variable and not > > via __MINGW_IMP_SYMBOL po

Re: [Mingw-w64-public] [RFC PATCH] headers: Simplify _HUGE definition

2022-10-09 Thread Pali Rohár
On Saturday 08 October 2022 23:57:06 LIU Hao wrote: > 在 2022-10-08 21:15, Pali Rohár 写道: > > > > Is not _CRTIMP automatically marking variable with dllimport and > > instruct compiler to convert variable name to __imp_name* pointer? > > Not always, at least. When bui

Re: [Mingw-w64-public] [RFC PATCH] headers: Simplify _HUGE definition

2022-10-10 Thread Pali Rohár
On Monday 10 October 2022 14:25:07 Martin Storsjö wrote: > Historically, the _CRTIMP macro comes from how it is used in upstream > msvcrt; you can link the CRT either statically or dynamically. If intending > to link statically, _CRTIMP expands to nothing, while if intending to link > dyanmically,

[Mingw-w64-public] #ifdef _MSVCRT_

2022-10-12 Thread Pali Rohár
Hello! More mingw-w64 header files contain '#ifdef _MSVCRT_' code. But _MSVCRT_ is not defined neither by gcc nor mingw-w64 runtime. So it is a dead code? Or is there any purpose for having those ifdefs? Note that gcc defines macro __MSVCRT__ with double underscores. _

Re: [Mingw-w64-public] #ifdef _MSVCRT_

2022-10-20 Thread Pali Rohár
On Tuesday 18 October 2022 12:01:34 LIU Hao wrote: > 在 2022/10/13 00:50, Pali Rohár 写道: > > Hello! More mingw-w64 header files contain '#ifdef _MSVCRT_' code. > > But _MSVCRT_ is not defined neither by gcc nor mingw-w64 runtime. > > So it is a dead code? Or is the

[Mingw-w64-public] Problems when building NT kernel drivers with GCC / LD

2022-10-29 Thread Pali Rohár
Hello! I tried to develop simple NT kernel driver and build it via GNU GCC, LD and mingw-w64 ecosystem but due to issues with compiler and linker, it is not possible to generate final .sys binary without adding workarounds or postprocessing resulted PE .sys binary. I'm sending this email to all p

Re: [Mingw-w64-public] Problems when building NT kernel drivers with GCC / LD

2022-11-04 Thread Pali Rohár
On Monday 31 October 2022 10:55:59 Jan Beulich wrote: > On 30.10.2022 02:06, Pali Rohár via Binutils wrote: > > * GCC or LD (not sure who) sets memory alignment characteristics > > (IMAGE_SCN_ALIGN_MASK) into the sections of PE executable binary. > > These characterist

Re: [Mingw-w64-public] Problems when building NT kernel drivers with GCC / LD

2022-11-04 Thread Pali Rohár
On Saturday 05 November 2022 01:57:49 Pali Rohár wrote: > On Monday 31 October 2022 10:55:59 Jan Beulich wrote: > > On 30.10.2022 02:06, Pali Rohár via Binutils wrote: > > > * GCC or LD (not sure who) sets memory alignment characteristics > > > (IMAGE_SCN_ALIGN_MA

[Mingw-w64-public] [PATCH] crt: Move C++ initialization comment in crtexe.c to correct line

2022-11-12 Thread Pali Rohár
Original comment (from commit 7b77ca866ca99) was not moved correctly in commit f9e8630d6f775. --- mingw-w64-crt/crt/crtexe.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c index 65303f818476..9093a2de29e7 100644 --- a

[Mingw-w64-public] [PATCH] crt: Move WinMain/wWinMain specific code outside of crtexe.c file

2022-11-12 Thread Pali Rohár
When application does not use WinMain() or wWinMain() entry point then there is no need to compute arguments for these entry points. So move WinMain/wWinMain specific code from crtexe.c file to crtexewin.c file. This new crtexewin.c file compute arguments for WinMain/wWinMain function and then dir

Re: [Mingw-w64-public] [PATCH] crt: Move WinMain/wWinMain specific code outside of crtexe.c file

2022-11-13 Thread Pali Rohár
On Sunday 13 November 2022 14:04:58 LIU Hao wrote: > 在 2022-11-12 21:36, Pali Rohár 写道: > > When application does not use WinMain() or wWinMain() entry point then > > there is no need to compute arguments for these entry points. > > > > > > This sounds great t

[Mingw-w64-public] [PATCH] crt: Use _TCHAR/_tmain/_tcslen in crtexe.c

2022-11-17 Thread Pali Rohár
Usage of _TCHAR/_tmain/_tcslen simplify code as it avoids #ifdef. Note that custom mingw-w64 wbytelen() function is replaced by 'sizeof(_TCHAR) * (_tcslen() + 1)' construction which expands to 2*(wcslen()+1) for unicode build. --- mingw-w64-crt/crt/crtexe.c | 55 +++---

[Mingw-w64-public] [PATCH] crt: Remove WPRFLAG macro

2022-11-17 Thread Pali Rohár
WPRFLAG is defined when _UNICODE is defined. So replace all usage of WPRFLAG by _UNICODE and remove unused WPRFLAG macro. --- mingw-w64-crt/crt/crtexe.c | 6 +++--- mingw-w64-crt/crt/dll_argv.c | 3 +-- mingw-w64-crt/crt/dllargv.c| 3 +-- mingw-w64-crt/crt/ucrtexe.c| 1 - mingw-w64-c

[Mingw-w64-public] [PATCH] crt: Remove unused __ImageBase from crt_handler.c

2022-11-18 Thread Pali Rohár
--- mingw-w64-crt/crt/crt_handler.c | 10 -- 1 file changed, 10 deletions(-) diff --git a/mingw-w64-crt/crt/crt_handler.c b/mingw-w64-crt/crt/crt_handler.c index fe52cf4e2a0d..c49a2b3b573d 100644 --- a/mingw-w64-crt/crt/crt_handler.c +++ b/mingw-w64-crt/crt/crt_handler.c @@ -13,16 +13,6 @

[Mingw-w64-public] [PATCH] crt: Use only __ImageBase symbol in mingw-w64 code

2022-11-18 Thread Pali Rohár
GNU LD provides __ImageBase symbol since 2.19. This is standard windows symbol and should be used instead of custom gnu _image_base__ symbol. For compatibility with older GNU LD versions, define __ImageBase as weak alias to _image_base__ symbol. This allows to remove all #ifdef hacks for older GN

Re: [Mingw-w64-public] [PATCH] crt: Use only __ImageBase symbol in mingw-w64 code

2022-11-19 Thread Pali Rohár
On Saturday 19 November 2022 17:12:12 LIU Hao wrote: > 在 2022-11-18 23:40, Pali Rohár 写道: > > GNU LD provides __ImageBase symbol since 2.19. This is standard windows > > symbol and should be used instead of custom gnu _image_base__ symbol. > > > > For compatibility

Re: [Mingw-w64-public] [PATCH] crt: Use only __ImageBase symbol in mingw-w64 code

2022-11-19 Thread Pali Rohár
On Saturday 19 November 2022 11:53:28 Pali Rohár wrote: > On Saturday 19 November 2022 17:12:12 LIU Hao wrote: > > 在 2022-11-18 23:40, Pali Rohár 写道: > > > GNU LD provides __ImageBase symbol since 2.19. This is standard windows > > > symbol and should be used instead

[Mingw-w64-public] [PATCH v2] crt: Use only __ImageBase symbol in mingw-w64 code

2022-11-20 Thread Pali Rohár
GNU LD provides __ImageBase symbol since 2.19. This is standard windows symbol and should be used instead of custom gnu _image_base__ symbol. Detect non-existence of __ImageBase symbol at ./configure time and for compatibility with older GNU LD versions, define __ImageBase symbol as alias to _imag

[Mingw-w64-public] gcc parameter -mcrtdll= for choosing Windows C RunTime DLL library

2022-11-20 Thread Pali Rohár
Hello! I would like to propose a new parameter for gcc: -mcrtdll= to allow specifying against which Windows C Runtime library should be binary linked. On Windows there are more crt libraries and currently gcc links to libmsvcrt.a which is in most cases symlink to libmsvcrt-os.a (but can be changed,

Re: [Mingw-w64-public] Problems when building NT kernel drivers with GCC / LD

2022-11-20 Thread Pali Rohár
On Saturday 05 November 2022 02:26:52 Pali Rohár wrote: > On Saturday 05 November 2022 01:57:49 Pali Rohár wrote: > > On Monday 31 October 2022 10:55:59 Jan Beulich wrote: > > > On 30.10.2022 02:06, Pali Rohár via Binutils wrote: > > > > * GCC or LD (not s

Re: [Mingw-w64-public] gcc parameter -mcrtdll= for choosing Windows C RunTime DLL library

2022-11-20 Thread Pali Rohár
On Sunday 20 November 2022 16:45:55 Eli Zaretskii wrote: > > Date: Sun, 20 Nov 2022 13:53:48 +0100 > > From: Pali Rohár via Gcc > > > > Hello! I would like to propose a new parameter for gcc: -mcrtdll= to > > allow specifying against which Windows C Runtime libra

Re: [Mingw-w64-public] gcc parameter -mcrtdll= for choosing Windows C RunTime DLL library

2022-11-20 Thread Pali Rohár
On Sunday 20 November 2022 21:36:19 LIU Hao wrote: > 在 2022-11-20 20:53, Pali Rohár 写道: > > Hello! I would like to propose a new parameter for gcc: -mcrtdll= to > > allow specifying against which Windows C Runtime library should be > > binary linked. On Windows there are m

Re: [Mingw-w64-public] gcc parameter -mcrtdll= for choosing Windows C RunTime DLL library

2022-11-20 Thread Pali Rohár
On Sunday 20 November 2022 17:23:15 Eli Zaretskii wrote: > > Date: Sun, 20 Nov 2022 16:04:11 +0100 > > From: Pali Rohár > > Cc: g...@gcc.gnu.org, mingw-w64-public@lists.sourceforge.net > > > > On Sunday 20 November 2022 16:45:55 Eli Zaretskii wrote: > > >

Re: [Mingw-w64-public] [PATCH v2] crt: Use only __ImageBase symbol in mingw-w64 code

2022-11-20 Thread Pali Rohár
On Sunday 20 November 2022 22:56:51 Martin Storsjö wrote: > On Sun, 20 Nov 2022, LIU Hao wrote: > > > 在 2022-11-20 19:23, Pali Rohár 写道: > > > GNU LD provides __ImageBase symbol since 2.19. This is standard windows > > > symbol and should be used instead of c

Re: [Mingw-w64-public] [PATCH v2] crt: Use only __ImageBase symbol in mingw-w64 code

2022-11-20 Thread Pali Rohár
On Sunday 20 November 2022 23:32:06 Martin Storsjö wrote: > On Sun, 20 Nov 2022, Pali Rohár wrote: > > > So at this point, do you think it's worth to add the complexity of > > > manually > > > expanding the linker test (like what was removed in > > > 6

Re: [Mingw-w64-public] Problems when building NT kernel drivers with GCC / LD

2022-11-26 Thread Pali Rohár
On Monday 21 November 2022 08:24:36 Jan Beulich wrote: > On 20.11.2022 14:10, Pali Rohár wrote: > > On Saturday 05 November 2022 02:26:52 Pali Rohár wrote: > >> On Saturday 05 November 2022 01:57:49 Pali Rohár wrote: > >>> On Monday 31 October 2022 10:55:59 Jan Beuli

Re: [Mingw-w64-public] gcc parameter -mcrtdll= for choosing Windows C RunTime DLL library

2022-11-26 Thread Pali Rohár
On Monday 21 November 2022 13:21:53 LIU Hao wrote: > 在 2022/11/20 23:06, Pali Rohár 写道: > > Thank you for explaining more details. My simple patch takes this in > > care and defines also __MSVCRT_VERSION__ to the correct value based on > > -mcrtdll parameter. > >

[Mingw-w64-public] [PATCH] crt: Define atoll/strto[u]ll/strto[iu]max functions for all msvcrt builds

2022-12-03 Thread Pali Rohár
Functions _atoi64, _strtoi64 and _strtoui64 are available since the first release of msvcrt.dll as part of MS Visual C++ 4.2. Define functions atoll, strtoll, strtoull, strtoimax and strtoumax as aliases for msvcrt _atoi64, _strtoi64 and _strtoui64 functions directly in def files. This would allow

[Mingw-w64-public] [PATCH] crt: Fix exports of crtdll.dll library

2022-12-03 Thread Pali Rohár
Symbols _ctype and _mbctype are DATA, like in all other crt libraries. Symbol _onexit is read-only function. And symbols _mkgmtime, _mkgmtime32 and _mkgmtime64 are not present in crtdll.dll at all. Calling gendef on crtdll.dll from Win NT 3.50 and Win 7 confirms it. --- mingw-w64-crt/lib32/crtdll.

Re: [Mingw-w64-public] gcc parameter -mcrtdll= for choosing Windows C RunTime DLL library

2022-12-04 Thread Pali Rohár
On Sunday 20 November 2022 13:53:48 Pali Rohár wrote: > Hello! I would like to propose a new parameter for gcc: -mcrtdll= to > allow specifying against which Windows C Runtime library should be > binary linked. On Windows there are more crt libraries and currently gcc > links to libms

Re: [Mingw-w64-public] [PATCH 1/3] crt: Add non-inline variant of UCRT _scprintf, _snprintf and _snscanf functions

2022-12-04 Thread Pali Rohár
On Wednesday 21 September 2022 11:31:54 Martin Storsjö wrote: > On Tue, 20 Sep 2022, Pali Rohár wrote: > > > > There are many, many different variants of inline behaviour - C89 inline, > > > C99 inline, static inline, extern inline, gnu_inline, etc. There's a > &

[Mingw-w64-public] [PATCH 1/2] crt: Move exported symbols from msvcrt-common.def.in to all files which include it

2022-12-06 Thread Pali Rohár
File msvcrt-common.def.in is included only in x86 32 and 64 bit msvcrt def files and common msvcrt.def.in file. After moving longjmp, _daylight, _timezone and _tzname out of the msvcrt-common.def.in file, this file would contain only symbol aliases and not export symbols anymore. This makes consist

[Mingw-w64-public] [PATCH 2/2] crt: Include moldname content for crtdll and msvcrt10, 20, 40, 70, 71

2022-12-06 Thread Pali Rohár
moldname content is already included in all other msvcrt def files. This allows applications to use moldname aliases defined in msvcrt-common.def.in also when linking with other crt dll libraries. --- mingw-w64-crt/Makefile.am | 3 ++- mingw-w64-crt/lib32/{crtdll.def =>

[Mingw-w64-public] [PATCH v2] crt: Move export symbols out of the msvcrt-common.def.in file

2022-12-11 Thread Pali Rohár
Include file msvcrt-common.def.in contains moldname aliases and 4 export symbols: longjmp, _daylight, _timezone, _tzname. Move these 4 export symbols from msvcrt-common.def.in file into all files which include msvcrt-common.def.in. So all msvcrt def files would contain all exported symbols directl

[Mingw-w64-public] [PATCH] crt: Remove unused lib64/moldname-msvcrt.def file

2022-12-11 Thread Pali Rohár
It is unused since commit 99c69c2fe5d8 ("lib64/msvcrt.def: include moldname contents") from April 2013. --- mingw-w64-crt/lib64/moldname-msvcrt.def | 149 1 file changed, 149 deletions(-) delete mode 100644 mingw-w64-crt/lib64/moldname-msvcrt.def diff --git a/mingw-w64-c

[Mingw-w64-public] [PATCH] crt: Fix type of daylight, timezone and tzname symbols in msvcrt-common.def.in

2022-12-17 Thread Pali Rohár
These symbols are global read/write variables and therefore must be declared with DATA keyword, even when they are just aliases to other symbols. Otherwise GNU dlltool generates for each of those symbols also function thunk code. --- mingw-w64-crt/def-include/msvcrt-common.def.in | 6 +++--- 1 fil

Re: [Mingw-w64-public] #ifdef _MSVCRT_

2022-12-17 Thread Pali Rohár
On Thursday 20 October 2022 21:44:36 Pali Rohár wrote: > On Tuesday 18 October 2022 12:01:34 LIU Hao wrote: > > 在 2022/10/13 00:50, Pali Rohár 写道: > > > Hello! More mingw-w64 header files contain '#ifdef _MSVCRT_' code. > > > But _MSVCRT_ is not defined

[Mingw-w64-public] [PATCH] crt: Fix building LTO version of mingw-w64 crt libraries

2022-12-17 Thread Pali Rohár
Currently when linking target application with LTO builds of mingw-w64 libraries, it is needed to manually specify entry point of mingw-w64 crt startup function via linker flag -Wl,-e,_mainCRTStartup (for console executables) or -Wl,-e,_WinMainCRTStartup (for GUI executables) or -Wl,-e,_DllMainCRTS

Re: [Mingw-w64-public] [PATCH] crt: Fix building LTO version of mingw-w64 crt libraries

2022-12-17 Thread Pali Rohár
On Saturday 17 December 2022 23:01:10 LIU Hao wrote: > 在 2022-12-17 22:22, Pali Rohár 写道: > > Currently when linking target application with LTO builds of mingw-w64 > > libraries, it is needed to manually specify entry point of mingw-w64 crt > > startup function v

[Mingw-w64-public] [PATCH 1/3] headers: Fix noreturn compile warning for __fastfail()

2022-12-18 Thread Pali Rohár
mingw-w64-headers/crt/_mingw.h: In function ‘__fastfail’: mingw-w64-headers/crt/_mingw.h:615:1: warning: ‘noreturn’ function does return } ^ --- mingw-w64-headers/crt/_mingw.h.in | 1 + 1 file changed, 1 insertion(+) diff --git a/mingw-w64-headers/crt/_mingw.h.in b/mingw-w64-h

[Mingw-w64-public] [PATCH 3/3] crt: Fix -Wimplicit-fallthrough for gdtoa

2022-12-18 Thread Pali Rohár
gdtoa/gethex.c: In function ‘__gethex_D2A’: gdtoa/gethex.c:127:10: warning: this statement may fall through [-Wimplicit-fallthrough=] esign = 1; ~~^~~ gdtoa/gethex.c:129:5: note: here case '+': ^~~~ gdtoa/dtoa.c: In function ‘__dtoa’: gdtoa

[Mingw-w64-public] [PATCH 2/3] crt: Fix -Wimplicit-fallthrough for mingw_pformat.c

2022-12-18 Thread Pali Rohár
stdio/mingw_pformat.c:2510:20: warning: this statement may fall through [-Wimplicit-fallthrough=] length = PFORMAT_LENGTH_LONG; ~~~^ stdio/mingw_pformat.c:2512:11: note: here case 'c': ^~~~ stdio/mi

[Mingw-w64-public] [PATCH] Remove old and unused msvcrt def file ms.def

2022-12-18 Thread Pali Rohár
--- mingw-w64-tools/genstubdll/sample/ms.def | 1416 -- 1 file changed, 1416 deletions(-) delete mode 100644 mingw-w64-tools/genstubdll/sample/ms.def diff --git a/mingw-w64-tools/genstubdll/sample/ms.def b/mingw-w64-tools/genstubdll/sample/ms.def deleted file mode 100644 ind

[Mingw-w64-public] [PATCH] crt: Define lldiv/imaxdiv functions for all msvcrt builds

2022-12-18 Thread Pali Rohár
Function lldiv() is available since msvcr100.dll and function imaxdiv() since msvcr120.dll. So for msvcr100.dll and msvcr110.dll define imaxdiv() as alias to lldiv(). And for older msvcrt versions include mingw-w64 implementation from imaxdiv.c. Do not pack mingw-w64 implementation of imaxdiv() int

  1   2   3   4   5   6   >