[Mingw-w64-public] snprintf() is broken in mingw-w64

2019-05-10 Thread Pali Rohár
uf=12 ret=9 Which is correct now. Would you consider fixing snprintf() in mingw-w64? Similarly also vsnprintf() can be fixed: #define vsnprintf(str, size, format, ap) ( (((size_t)(size) > 0) ? (_vsnprintf((str), (size), (format), (ap)), ((char *)str)[(size_t)(size)-1] = 0, 0) : 0), _vscprin

Re: [Mingw-w64-public] snprintf() is broken in mingw-w64

2020-02-20 Thread Pali Rohár
resending this email again. Btw, if macro is not suitable then it is possible to write normal snprintf function which would call _snprintf() and _scprintf() as in that macro. On Friday 03 May 2019 10:39:46 Pali Rohár wrote: > Hello! > > snprintf() function in mingw-w64 is brok

Re: [Mingw-w64-public] snprintf() is broken in mingw-w64

2020-02-20 Thread Pali Rohár
() wrapper is needed. PS: Please CC me as I'm not subscribed to list. On Sunday 16 February 2020 22:03:21 Pali Rohár wrote: > Hello! Year ago I sent this email about snprintf() problem in mingw-w64 > but I have not received any response yet. > > For one week I tried to contact mingw-w64 devel

[Mingw-w64-public] [PATCH] Enable __USE_MINGW_ANSI_STDIO for C99 and C++11 when not using UCRT

2020-04-28 Thread Pali Rohár
C99 and C++11 standards requires printf ll modifier for long long type but it does not work in WinXP system msvcrt.dll. It requires at least library msvcr80.dll. So when gcc is invoked with --std=c99 (or new) or --std=c++11 (or new) ansi stdio macro needs to be enabled for printf ll modifier

[Mingw-w64-public] [PATCH] Allow to use __USE_MINGW_ANSI_STDIO with msvcr80.dll

2020-04-28 Thread Pali Rohár
Trying to link application with msvcr80.dll instead of msvcrt.dll (e.g. by replacing -lmsvcrt by -lmsvcr80 in gcc spec file) results in following linker error: .../lib/crt2.o: in function `_tmainCRTStartup': .../mingw-w64-crt/crt/crtexe.c:290: undefined reference to

Re: [Mingw-w64-public] [PATCH] Enable __USE_MINGW_ANSI_STDIO for C99 and C++11 when not using UCRT

2020-04-30 Thread Pali Rohár
nition error should not be triggered as C99 allows you to have one inline and one non-inline definition of the same function. And I think after adding "inline" for function definition in header file, patch which Liu Hao posted should not be needed. -- Pali Rohár pali.ro...@gmail.com

Re: [Mingw-w64-public] [PATCH] Allow to use __USE_MINGW_ANSI_STDIO with msvcr80.dll

2020-04-30 Thread Pali Rohár
On Tuesday 28 April 2020 22:02:35 Liu Hao wrote: > 在 2020/4/28 15:21, Pali Rohár 写道: > > Trying to link application with msvcr80.dll instead of msvcrt.dll (e.g. by > > replacing -lmsvcrt by -lmsvcr80 in gcc spec file) results in following > > linker error: > > >

Re: [Mingw-w64-public] [PATCH] crt: Add missing functions in msvcr80.def

2020-04-30 Thread Pali Rohár
On Thursday 30 April 2020 10:17:55 Liu Hao wrote: > 在 2020/4/30 2:31, Pali Rohár 写道: > > On Wednesday 29 April 2020 22:20:57 Liu Hao wrote: > > > > The application failed to initialize properly (0xc142). Click OK to > > terminate application. > &g

Re: [Mingw-w64-public] [PATCH] Enable __USE_MINGW_ANSI_STDIO for C99 and C++11 when not using UCRT

2020-04-30 Thread Pali Rohár
On Thursday 30 April 2020 08:17:04 Martin Storsjö wrote: > On Wed, 29 Apr 2020, Liu Hao wrote: > > > 在 2020/4/28 15:22, Pali Rohár 写道: > > > C99 and C++11 standards requires printf ll modifier for long long type but > > > it does not work in WinXP system msvcrt.dll

Re: [Mingw-w64-public] [PATCH] crt: Add missing functions in msvcr80.def

2020-04-30 Thread Pali Rohár
On Wednesday 29 April 2020 22:20:57 Liu Hao wrote: > 在 2020/4/28 23:47, Pali Rohár 写道: > > > > They really exist in my tested msvcr80.dll file! > > > > I thought that if symbols are missing in mingw def files then functions > > are unimplemented. But it looks

Re: [Mingw-w64-public] [PATCH] crt: Add missing functions in msvcr80.def

2020-04-30 Thread Pali Rohár
On Wednesday 29 April 2020 22:20:57 Liu Hao wrote: > 在 2020/4/28 23:47, Pali Rohár 写道: > > > > They really exist in my tested msvcr80.dll file! > > > > I thought that if symbols are missing in mingw def files then functions > > are unimplemented. But it looks

Re: [Mingw-w64-public] [PATCH] crt: Add missing functions in msvcr80.def

2020-04-30 Thread Pali Rohár
On Thursday 30 April 2020 17:22:52 Liu Hao wrote: > 在 2020/4/30 17:14, Pali Rohár 写道: > > > > So problem is only with 80, not 90. > > > > Anyway, that error message is issued by msvcr80.dll library itself, so I > > think it could be possible to do some

Re: [Mingw-w64-public] [PATCH] Enable __USE_MINGW_ANSI_STDIO for C99 and C++11 when not using UCRT

2020-04-30 Thread Pali Rohár
On Thursday 30 April 2020 17:13:05 Liu Hao wrote: > 在 2020/4/30 16:43, Pali Rohár 写道: > > > > I think there is another problem: > > > > Function wcstof() which is in mingw-w64-headers/crt/stdlib.h should be > > marked as "inline". Otherwise there c

Re: [Mingw-w64-public] snprintf() is broken in mingw-w64

2020-04-30 Thread Pali Rohár
On Friday 21 February 2020 17:22:13 Pali Rohár wrote: > On Friday 21 February 2020 18:17:37 Liu Hao wrote: > > 在 2020/2/21 2:27, Pali Rohár 写道: > > > Hello! Based on raymod2 suggestion on IRC, I prepared full patch and > > > tested it that snprintf() and

[Mingw-w64-public] [PATCH] _mingw.h: Do not check for _UCRT

2020-04-30 Thread Pali Rohár
This fixes commit bfd33f6c0ec5e652cc9911857dd1492ece8d8383. _UCRT does not have to be defined yet (it is defined after including _mingw.h), but __MSVCRT_VERSION__ at this stage is always defined (few lines above). --- mingw-w64-headers/crt/_mingw.h.in | 4 ++-- 1 file changed, 2 insertions(+), 2

Re: [Mingw-w64-public] [PATCH] crt: Add missing functions in msvcr80.def

2020-05-31 Thread Pali Rohár
On Thursday 30 April 2020 11:29:47 Pali Rohár wrote: > On Thursday 30 April 2020 17:22:52 Liu Hao wrote: > > 在 2020/4/30 17:14, Pali Rohár 写道: > > > > > > So problem is only with 80, not 90. > > > > > > Anyway, that error message is issued by msvcr80.

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 fa

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: 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

[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,

[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

[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

[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

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

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-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

[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

[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

[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

[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()

[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

[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

[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-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 |

[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-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

[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-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-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-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

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] 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

[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(+),

[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

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

[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] 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

[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%)

[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

[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 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

[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()

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 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

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

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] 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

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 there any pur

[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

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

[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 +-

[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

[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 +++

[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

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] #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] [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] [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: [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-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] [PATCH] crt: Fix building LTO version of mingw-w64 crt libraries

2022-12-24 Thread Pali Rohár
On Saturday 24 December 2022 11:48:51 LIU Hao wrote: > 在 2022-12-24 06:14, Pali Rohár 写道: > > I just quickly tested it only in wine. Without LTO it prints "ł$" > > (really strange, looks like some memory problem, maybe in wine?). > > > >

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

2022-12-25 Thread Pali Rohár
On Sunday 25 December 2022 17:21:50 LIU Hao wrote: > 在 2022-12-25 02:19, Pali Rohár 写道: > > This patch fixes it! And also in LTO mode it prints "test thread atexit". > > > > Mostly good. Should `__xl_d` be given an attribute as well? It is not referenced anywher

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

2022-12-22 Thread Pali Rohár
On Wednesday 21 December 2022 14:54:13 Martin Storsjö wrote: > On Sat, 17 Dec 2022, LIU Hao wrote: > > > 在 2022-12-17 20:01, Pali Rohár 写道: > > > It would be nice if somebody who understand these patterns write some > > > comment what is the real purpose of the fi

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

2022-12-26 Thread Pali Rohár
Hello! I would like to remind this thread for gcc/binutils developers. Most of these issues are still present and cause problems for compiling native PE binary. If you have questions or you need any other information please let me know. On Sunday 30 October 2022 02:06:11 Pali Rohár wrote: > He

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

2022-12-23 Thread Pali Rohár
On Friday 23 December 2022 22:25:57 LIU Hao wrote: > 在 2022-12-21 21:00, Martin Storsjö 写道: > > > > I believe this patch should be harmless; for regular object file based > > linking, __attribute__((used)) shouldn't have any effect across object > > file boundaries (it only affects what's emitted

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

2022-12-23 Thread Pali Rohár
On Friday 23 December 2022 22:20:25 LIU Hao wrote: > 在 2022-12-04 21:49, Pali Rohár 写道: > > Format attributes is interesting issue. Because there are already following > > printf implementations: > > > > 1) C89 (without %lld) (crtdll.dll, msvcrt10.dll) > > 2) C

[Mingw-w64-public] snprintf without stdio.h does not work

2022-12-28 Thread Pali Rohár
Hello! I did another test on master branch of mingw-w64 with very simple snprintf test.c program which does not include any header file: typedef long unsigned int size_t; int __cdecl snprintf(char *buffer, size_t n, const char *format, ...); int main(int argc, char *argv[]) { char

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

2022-12-28 Thread Pali Rohár
On Saturday 19 November 2022 15:42:45 Pali Rohár wrote: > 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

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

2022-12-29 Thread Pali Rohár
On Thursday 29 December 2022 13:09:18 Martin Storsjö wrote: > > > The question is now how to handle this issue? Based on this testing, I > > > do not see what can be done. weak should not be used, LTO also (and does > > > not work with old gcc), moving symbol to header file does not sounds > > >

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

2022-12-23 Thread Pali Rohár
On Saturday 24 December 2022 03:17:57 LIU Hao wrote: > 在 2022-12-24 01:43, Pali Rohár 写道: > > Ou right. They would also require __attribute__((used)) for LTO builds. > > I just tested simple single process/thread console applications and they > > worked. > > &g

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

2022-12-23 Thread Pali Rohár
On Saturday 24 December 2022 01:00:59 LIU Hao wrote: > 在 2022-12-24 00:18, Pali Rohár 写道: > > What is the reason? Maybe it was gcc/ld bug which this patch workarounds? > > > > Generally speaking, all variables that are required to be placed in special >

Re: [Mingw-w64-public] [PATCH] crt: Preserve special variables when LTO is in effect

2022-12-27 Thread Pali Rohár
On Tuesday 27 December 2022 14:38:00 LIU Hao wrote: > Variables that are required to be placed in explicit sections probably > have special meanings, and shall not be eliminated by LTO. Preserving > all of them might look an overkill, but should be safest. > > Signed-off-by: LIU Hao > --- >

[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

[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

[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 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

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 neither b

[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

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] 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

[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

[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()

  1   2   3   >