[Mingw-w64-public] make sure WINPTHREAD_API is correctly defined in pthread_time.h

2025-02-07 Thread Kirill Makurin
See attached patch. - Kirill Makurin From 87951029ce19f763ebf28262bf0bb3a48fbed0c2 Mon Sep 17 00:00:00 2001 From: Kirill Makurin Date: Sat, 8 Feb 2025 01:45:40 +0900 Subject: [PATCH] winpthreads: make sure WINPTHREAD_API is correctly defined in pthread_time.h When building with MSVC, pthread_ti

Re: [Mingw-w64-public] [PATCH v2 2/2] crt: Call the regular sin()/cos() functions in sincos() on UCRT/x86

2025-02-07 Thread Jacek Caban
On 7.02.2025 10:22, Martin Storsjö wrote: On Fri, 7 Feb 2025, LIU Hao wrote: 在 2025-02-06 22:23, Jacek Caban 写道: FWIW, that's the approach we take in Wine for entire CRT modules (not just static parts like mingw- w64-crt's counterpart), and it works well. Most optimizations lost this way can

Re: [Mingw-w64-public] headers: Add new symbols in mapi.h

2025-02-07 Thread LIU Hao
在 2025-02-07 16:58, Biswapriyo Nath 写道: From d47f41050fbf562125fa1471ca1b88634006afa2 Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Fri, 7 Feb 2025 08:57:03 + Subject: [PATCH] headers: Add new symbols in mapi.h Fixeshttps://github.com/mingw-w64/mingw-w64/issues/75 Signed-off-by: Bis

[Mingw-w64-public] [PATCH 10/15] crt: Inline pre_c_init() into _CRT_INIT() in crtdll.c

2025-02-07 Thread Pali Rohár
This allows to remove the whole pre_c_init() function and registration of pcinit hook. --- mingw-w64-crt/crt/crtdll.c | 13 +++-- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c index 797a8ab54e1d..6c6ea38f03f7 100644

[Mingw-w64-public] [PATCH 09/15] crt: Inline __DllMainCRTStartup() into DllMainCRTStartup()

2025-02-07 Thread Pali Rohár
Usage of separate static function __DllMainCRTStartup() is needed for MSVC stack cookie handling as written in documentation for C Runtime Error R6035: https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/c-runtime-error-r6035 mingw-w64 does not support MSVC stack cookie handling, it w

[Mingw-w64-public] [PATCH 15/15] crt: Remove DllEntryPoint from DLL builds

2025-02-07 Thread Pali Rohár
Function with name DllEntryPoint is entry point of the DLL library, an alternative or aliased name to DllMainCRTStartup. So calling entry point (DllEntryPoint) from entry point (DllMainCRTStartup) is just wrong. Default DLL entry point function varies between compilers/linkers. Borland C uses DllE

[Mingw-w64-public] [PATCH 08/15] crt: Move mingw-w64 / gcc DLL runtime code from __DllMainCRTStartup() to _CRT_INIT()

2025-02-07 Thread Pali Rohár
For DLL builds, move calling __main(), _pei386_runtime_relocator() and __mingw_init_ehandler() functions from __DllMainCRTStartup() into _CRT_INIT() function. This allow applications with custom entry point, which would call _CRT_INIT() manually, to work correctly. Also _CRT_INIT() contains guard

[Mingw-w64-public] [PATCH 12/15] crt: Remove usage of _DLL macro

2025-02-07 Thread Pali Rohár
This macro is always defined by _mingw.h and its value is not checked by any header file. So remove usage of this macro in .c files and dead code of code paths when not set. --- mingw-w64-crt/crt/crtdll.c | 8 mingw-w64-crt/crt/crtexe.c | 4 2 files changed, 12 deletions(-) diff --g

[Mingw-w64-public] [PATCH 04/15] crt: Guard nested _CRT_INIT(DLL_PROCESS_DETACH) call for DLL builds

2025-02-07 Thread Pali Rohár
This will report runtime error if _CRT_INIT(DLL_PROCESS_DETACH) is called by the current thread from some atexit_table hook. Without this guard the _CRT_INIT(DLL_PROCESS_DETACH) function stay in the infinite loop. Startup code from Visual C++ runtime is doing same thing. --- mingw-w64-crt/crt/cr

[Mingw-w64-public] [PATCH 13/15] crt: Remove usage of SPECIAL_CRTEXE macro

2025-02-07 Thread Pali Rohár
This macro is only set but not used by any mingw-w64 file. --- mingw-w64-crt/crt/binmode.c | 2 -- mingw-w64-crt/crt/crtexe.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/mingw-w64-crt/crt/binmode.c b/mingw-w64-crt/crt/binmode.c index f0473b086a56..18b15d1baaf4 100644 --- a/mingw-w64-crt

[Mingw-w64-public] [PATCH 07/15] crt: Properly release __native_startup_lock on _CRT_INIT(DLL_PROCESS_ATTACH) failure

2025-02-07 Thread Pali Rohár
--- mingw-w64-crt/crt/crtdll.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c index b7f2d183312f..6028d0c776f0 100644 --- a/mingw-w64-crt/crt/crtdll.c +++ b/mingw-w64-crt/crt/crtdll.c @@ -78,6 +78,7 @@ WINBOOL

[Mingw-w64-public] [PATCH 11/15] crt: Remove usage of CRTDLL macro

2025-02-07 Thread Pali Rohár
This macro is used only on few places in .c files, not in .h files. So remove its usage and dead code. --- mingw-w64-crt/crt/crtdll.c | 7 --- mingw-w64-crt/crt/crtexe.c | 1 - mingw-w64-crt/crt/dll_argv.c | 4 mingw-w64-crt/crt/dllargv.c | 4 mingw-w64-crt/crt/tlssup.c | 4 --

[Mingw-w64-public] [PATCH 14/15] crt: Remove custom declaration of _initterm() and DllMain() functions from crtdll.c

2025-02-07 Thread Pali Rohár
Function _initterm() is declared in corecrt_startup.h and DllMain() in process.h --- mingw-w64-crt/crt/crtdll.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c index 87ab29b14136..d63915ca30a3 100644 --- a/mingw-w64-crt/crt/crtdll.c +++

[Mingw-w64-public] [PATCH 02/15] crt: Explicitly initialize __native_startup_state and __native_startup_lock variables to prevent C tentative definitions

2025-02-07 Thread Pali Rohár
--- mingw-w64-crt/crt/natstart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mingw-w64-crt/crt/natstart.c b/mingw-w64-crt/crt/natstart.c index 0afbaa801a9a..5008790e1eef 100644 --- a/mingw-w64-crt/crt/natstart.c +++ b/mingw-w64-crt/crt/natstart.c @@ -10,5 +10,5 @@ _PGL

[Mingw-w64-public] [PATCH 06/15] crt: Guard negative __proc_attached value for DllMainCRTStartup(DLL_PROCESS_DETACH)

2025-02-07 Thread Pali Rohár
--- mingw-w64-crt/crt/crtdll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c index eefe0e0715bd..b7f2d183312f 100644 --- a/mingw-w64-crt/crt/crtdll.c +++ b/mingw-w64-crt/crt/crtdll.c @@ -171,7 +171,7 @@ __DllMainCRTStart

[Mingw-w64-public] [PATCH 01/15] crt: Fix type of __native_startup_lock variable

2025-02-07 Thread Pali Rohár
The variable __native_startup_lock should be volatile. But currently its type is "volatile void *", which means that the dereferenced pointer value is volatile, not the variable itself. Currently the compiler is throwing a warning when the variable is used by InterlockedCompareExchangePointer() or

[Mingw-w64-public] [PATCH 05/15] crt: Guard multiple _CRT_INIT(DLL_PROCESS_ATTACH) call for DLL builds

2025-02-07 Thread Pali Rohár
This will report runtime error if _CRT_INIT(DLL_PROCESS_ATTACH) is called two or more times. Without this guard the _CRT_INIT(DLL_PROCESS_ATTACH) may be unexpectely called multiple times which will break __proc_attached counter and then also the DLL_PROCESS_DETACH code path. Startup code from Vis

[Mingw-w64-public] [PATCH 03/15] crt: Use BOOL type for boolean variable nested

2025-02-07 Thread Pali Rohár
--- mingw-w64-crt/crt/crtdll.c | 2 +- mingw-w64-crt/crt/crtexe.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c index a8b95ec50d59..bf2399d27e57 100644 --- a/mingw-w64-crt/crt/crtdll.c +++ b/mingw-w64-crt/crt/crtdll.c

Re: [Mingw-w64-public] [PATCH v2 2/2] crt: Call the regular sin()/cos() functions in sincos() on UCRT/x86

2025-02-07 Thread Martin Storsjö
On Fri, 7 Feb 2025, LIU Hao wrote: 在 2025-02-06 22:23, Jacek Caban 写道: FWIW, that's the approach we take in Wine for entire CRT modules (not just static parts like mingw- w64-crt's counterpart), and it works well. Most optimizations lost this way can be addressed by writing efficient C code f

[Mingw-w64-public] headers: Add new symbols in mapi.h

2025-02-07 Thread Biswapriyo Nath
From d47f41050fbf562125fa1471ca1b88634006afa2 Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Fri, 7 Feb 2025 08:57:03 + Subject: [PATCH] headers: Add new symbols in mapi.h Fixes https://github.com/mingw-w64/mingw-w64/issues/75 Signed-off-by: Biswapriyo Nath --- mingw-w64-headers/inc