Re: [Mingw-w64-public] [PATCH 2/2] crt: Align i386 stack to 16-bytes for DLL builds due to SSE

2024-12-03 Thread LIU Hao
在 2024-12-04 03:52, Pali Rohár 写道: This feels like a typo - I presume it should say "in DllMain/DllEntryPoint or in functions called _by_ DllMain/DllEntryPoint"? I see that the existing case in crtexe.c has a similar typo. I copied the comment from the crtexe.c. It looks like that there is miss

Re: [Mingw-w64-public] [PATCH 2/2] headers: Declare debug _CRTDBG_MAP_ALLOC macros

2024-12-03 Thread LIU Hao
在 2024-12-04 04:17, Pali Rohár 写道: It allowed me to compile application in debug mode with msvcrtd.dll memory leak detector and then run it. It was compiled in the same way via gcc and msvc. I do not know a better way how to define those functions without locally undefining macros. Is there some

[Mingw-w64-public] [PATCH] crt: Fix t_vsscanf test case

2024-12-03 Thread Pali Rohár
Test must exit with status code 0 on success. memcmp() returns 0 when two buffers are same, so use directly value from memcmp() as status code. --- mingw-w64-crt/testcases/t_vsscanf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mingw-w64-crt/testcases/t_vsscanf.c b/mingw-w

Re: [Mingw-w64-public] [PATCH 3/4] crt: Move vscanf-family functions from libmingwex.a to individual CRT import libraries

2024-12-03 Thread Pali Rohár
On Wednesday 04 December 2024 00:23:44 Martin Storsjö wrote: > On Tue, 3 Dec 2024, Pali Rohár wrote: > > > Another option without touching binfmt-misc is misuse of automake > > LOG_COMPILER env variable. It is prepended before spawning any test, > > I guess it is for logging purpose. But it can be

Re: [Mingw-w64-public] [PATCH] crt: Avoid calling memset in crt_handler.c

2024-12-03 Thread Pali Rohár
On Wednesday 04 December 2024 00:02:11 Martin Storsjö wrote: > On Tue, 3 Dec 2024, Pali Rohár wrote: > > > It is not visible in the diff, but the functions starts with > > > > int > > __mingw_init_ehandler (void) > > { > >static int was_here = 0; > >size_t e = 0; > >PIMAGE_SECTION_

Re: [Mingw-w64-public] [PATCH 3/4] crt: Move vscanf-family functions from libmingwex.a to individual CRT import libraries

2024-12-03 Thread Martin Storsjö
On Tue, 3 Dec 2024, Pali Rohár wrote: Another option without touching binfmt-misc is misuse of automake LOG_COMPILER env variable. It is prepended before spawning any test, I guess it is for logging purpose. But it can be also wine which then spawns exe binary. So for example: make check LOG_C

Re: [Mingw-w64-public] [PATCH 4/4] crt: Add t_vsscanf test case

2024-12-03 Thread Martin Storsjö
On Tue, 3 Dec 2024, Pali Rohár wrote: On Tuesday 19 November 2024 13:42:19 Pali Rohár wrote: --- mingw-w64-crt/Makefile.am | 1 + mingw-w64-crt/testcases/t_vsscanf.c | 33 + 2 files changed, 34 insertions(+) create mode 100644 mingw-w64-crt/testcases/t_v

Re: [Mingw-w64-public] [PATCH] crt: Avoid calling memset in crt_handler.c

2024-12-03 Thread Martin Storsjö
On Tue, 3 Dec 2024, Pali Rohár wrote: It is not visible in the diff, but the functions starts with int __mingw_init_ehandler (void) { static int was_here = 0; size_t e = 0; PIMAGE_SECTION_HEADER pSec; PBYTE _ImageBase = _GetPEImageBase (); if (was_here || !_ImageBase) re

Re: [Mingw-w64-public] [PATCH 4/4] crt: Add t_vsscanf test case

2024-12-03 Thread Pali Rohár
On Tuesday 19 November 2024 13:42:19 Pali Rohár wrote: > --- > mingw-w64-crt/Makefile.am | 1 + > mingw-w64-crt/testcases/t_vsscanf.c | 33 + > 2 files changed, 34 insertions(+) > create mode 100644 mingw-w64-crt/testcases/t_vsscanf.c > > diff --git a/mingw

Re: [Mingw-w64-public] [PATCH] crt: Avoid calling memset in crt_handler.c

2024-12-03 Thread Pali Rohár
On Tuesday 03 December 2024 16:27:15 Martin Storsjö wrote: > On Tue, 3 Dec 2024, Martin Storsjö wrote: > > > On Wed, 27 Nov 2024, Pali Rohár wrote: > > > > > Explicitly initialize variable to zeros, which has same effect as > > > initialzing it via memset. > > > --- > > > mingw-w64-crt/crt/crt_ha

Re: [Mingw-w64-public] [PATCH 2/2] headers: Declare debug _CRTDBG_MAP_ALLOC macros

2024-12-03 Thread Pali Rohár
On Tuesday 03 December 2024 23:28:02 LIU Hao wrote: > 在 2024-12-03 22:16, Martin Storsjö 写道: > > This patch also seems ok to me. > > > > On first look, this feels like it adds a lot of noise to the headers, > > but I guess it's not all that bad. So I can push it if nobody else > > objects to it. >

Re: [Mingw-w64-public] [PATCH] gendef: Recognize PE binaries which do not have all Data Directories

2024-12-03 Thread Pali Rohár
On Tuesday 03 December 2024 16:35:38 Martin Storsjö wrote: > On Fri, 29 Nov 2024, Pali Rohár wrote: > > > PE format allows to have variable length of Data Directories in PE Optional > > Header. The exact number of Data Directories is stored in > > NumberOfRvaAndSizes > > field. Size of the option

Re: [Mingw-w64-public] [PATCH 2/2] crt: Align i386 stack to 16-bytes for DLL builds due to SSE

2024-12-03 Thread Pali Rohár
On Tuesday 03 December 2024 16:22:05 Martin Storsjö wrote: > On Wed, 27 Nov 2024, Pali Rohár wrote: > > > i386 DLL builds have same issue as EXE builds, entry point (DllMain or > > DllEntryPoint) can use SSE and therefore stack should be aligned to > > 16-bytes. Use attribute force_align_arg_point

Re: [Mingw-w64-public] [PATCH 1/2] crt: Call __mingw_init_ehandler() after _pei386_runtime_relocator() also for DLL builds

2024-12-03 Thread Pali Rohár
On Tuesday 03 December 2024 16:19:58 Martin Storsjö wrote: > On Wed, 27 Nov 2024, Pali Rohár wrote: > > > For EXE builds __mingw_init_ehandler() function is called after the > > _pei386_runtime_relocator() from the __tmainCRTStartup() (and not from the > > WinMainCRTStartup() function). > > > > D

Re: [Mingw-w64-public] [PATCH] crt: Localize usage of startinfo variable

2024-12-03 Thread Pali Rohár
On Tuesday 03 December 2024 16:33:01 Martin Storsjö wrote: > On Wed, 27 Nov 2024, Pali Rohár wrote: > > > Variable startinfo is used only by __(w)getmainargs() call passed by the > > pointer in pre_cpp_init() function. The __(w)getmainargs() function does > > not use or store the pointer value, so

Re: [Mingw-w64-public] [PATCH 3/4] crt: Move vscanf-family functions from libmingwex.a to individual CRT import libraries

2024-12-03 Thread Pali Rohár
On Tuesday 03 December 2024 16:12:33 Martin Storsjö wrote: > On Tue, 3 Dec 2024, LIU Hao wrote: > > > 在 2024-12-03 21:52, Martin Storsjö 写道: > > > I didn't look at the added test here (and not much on the test added > > > in an earlier patch series either); I'm not familiar with how to > > > build

Re: [Mingw-w64-public] [PATCH 2/2] headers: Declare debug _CRTDBG_MAP_ALLOC macros

2024-12-03 Thread LIU Hao
在 2024-12-03 22:16, Martin Storsjö 写道: This patch also seems ok to me. On first look, this feels like it adds a lot of noise to the headers, but I guess it's not all that bad. So I can push it if nobody else objects to it. // Martin The changes are fine if they match Microsoft headers. --

Re: [Mingw-w64-public] [PATCH] gendef: Recognize PE binaries which do not have all Data Directories

2024-12-03 Thread Martin Storsjö
On Fri, 29 Nov 2024, Pali Rohár wrote: PE format allows to have variable length of Data Directories in PE Optional Header. The exact number of Data Directories is stored in NumberOfRvaAndSizes field. Size of the optional header depends on the number of Data Directories. Constants IMAGE_SIZEOF_N

Re: [Mingw-w64-public] [PATCH 2/2] headers: Declare debug _CRTDBG_MAP_ALLOC macros

2024-12-03 Thread Martin Storsjö
On Wed, 27 Nov 2024, Pali Rohár wrote: In Visual Studio when including crtdbg.h file with both _DEBUG and _CRTDBG_MAP_ALLOC macros set, all standard memory allocation functions are redefined and forwarded to their *_dbg siblings. This allows to track memory allocation in program compiled and lin

Re: [Mingw-w64-public] [PATCH] crt: Localize usage of startinfo variable

2024-12-03 Thread Martin Storsjö
On Wed, 27 Nov 2024, Pali Rohár wrote: Variable startinfo is used only by __(w)getmainargs() call passed by the pointer in pre_cpp_init() function. The __(w)getmainargs() function does not use or store the pointer value, so the variable does not have to be static. Declare this variable just on t

Re: [Mingw-w64-public] [PATCH] crt: Replace wprintf() by __ms_wprintf() call and use %ls for wchar_t* types

2024-12-03 Thread Martin Storsjö
On Wed, 27 Nov 2024, Pali Rohár wrote: This ensures that mingwex wprintf implementation will not be used and statically linked when not needed. And also make it more predictable as %ls format is always using wide string. But the mingwex implementation shouldn't really be used here anyway? All

Re: [Mingw-w64-public] [PATCH] crt: Avoid calling memset in crt_handler.c

2024-12-03 Thread Martin Storsjö
On Tue, 3 Dec 2024, Martin Storsjö wrote: On Wed, 27 Nov 2024, Pali Rohár wrote: Explicitly initialize variable to zeros, which has same effect as initialzing it via memset. --- mingw-w64-crt/crt/crt_handler.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) LGTM, pushed. Thanks!

Re: [Mingw-w64-public] [PATCH] crt: Avoid calling memset in crt_handler.c

2024-12-03 Thread Martin Storsjö
On Wed, 27 Nov 2024, Pali Rohár wrote: Explicitly initialize variable to zeros, which has same effect as initialzing it via memset. --- mingw-w64-crt/crt/crt_handler.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) LGTM, pushed. Thanks! // Martin ___

Re: [Mingw-w64-public] [PATCH 2/2] crt: Align i386 stack to 16-bytes for DLL builds due to SSE

2024-12-03 Thread Martin Storsjö
On Wed, 27 Nov 2024, Pali Rohár wrote: i386 DLL builds have same issue as EXE builds, entry point (DllMain or DllEntryPoint) can use SSE and therefore stack should be aligned to 16-bytes. Use attribute force_align_arg_pointer for __DllMainCRTStartup, like it is already for __tmainCRTStartup. Als

Re: [Mingw-w64-public] [PATCH 1/2] crt: Call __mingw_init_ehandler() after _pei386_runtime_relocator() also for DLL builds

2024-12-03 Thread Martin Storsjö
On Wed, 27 Nov 2024, Pali Rohár wrote: For EXE builds __mingw_init_ehandler() function is called after the _pei386_runtime_relocator() from the __tmainCRTStartup() (and not from the WinMainCRTStartup() function). Do same for DLL builds and call __mingw_init_ehandler() from __DllMainCRTStartup()

Re: [Mingw-w64-public] [PATCH 1/2] headers: Declare CRT debug functions and macros for CRT debug DLL

2024-12-03 Thread Martin Storsjö
On Wed, 27 Nov 2024, Pali Rohár wrote: msvc compiler for msvcrt and ucrt debug builds declare debug CRT function when _DEBUG macro is defined. All those functions and macros are defined in crtdbg.h include file. Do same in mingw-w64 headers. This allows applications to be compiled with gcc's -m

Re: [Mingw-w64-public] [PATCH 3/4] crt: Move vscanf-family functions from libmingwex.a to individual CRT import libraries

2024-12-03 Thread Martin Storsjö
On Tue, 3 Dec 2024, LIU Hao wrote: 在 2024-12-03 21:52, Martin Storsjö 写道: I didn't look at the added test here (and not much on the test added in an earlier patch series either); I'm not familiar with how to build/run those tests. Can you briefly tell me how to use them? And is it possible to

Re: [Mingw-w64-public] [PATCH 3/4] crt: Move vscanf-family functions from libmingwex.a to individual CRT import libraries

2024-12-03 Thread LIU Hao
在 2024-12-03 21:52, Martin Storsjö 写道: I didn't look at the added test here (and not much on the test added in an earlier patch series either); I'm not familiar with how to build/run those tests. Can you briefly tell me how to use them? And is it possible to execute the tests e.g. wrapped in win

Re: [Mingw-w64-public] [PATCH] headers: Split wincon.h into separate consoleapi headers

2024-12-03 Thread LIU Hao
在 2024-12-03 01:54, Biswapriyo Nath 写道: From 30a2ef8a7e33e759eebd74dd4dddfcd1f4acd35b Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Mon, 2 Dec 2024 17:53:18 + Subject: [PATCH] headers: Split wincon.h into separate consoleapi headers Fixeshttps://github.com/mingw-w64/mingw-w64/issues/

Re: [Mingw-w64-public] [PATCH 3/4] crt: Move vscanf-family functions from libmingwex.a to individual CRT import libraries

2024-12-03 Thread Martin Storsjö
On Fri, 29 Nov 2024, Pali Rohár wrote: On Saturday 30 November 2024 00:46:09 Martin Storsjö wrote: On Fri, 29 Nov 2024, Martin Storsjö wrote: On Tue, 19 Nov 2024, Pali Rohár wrote: The stdio/scanf.S file has got quite good comments explaining parts of it. But some parts of the comments ther