1
0
mirror of https://git.code.sf.net/p/mingw-w64/mingw-w64 synced 2025-04-18 17:44:18 +03:00

8178 Commits

Author SHA1 Message Date
Pali Rohár
3a4102aa4b crt: Restore ftime symbol also for UCRT builds
Fixes commit ee481ee9392c ("crt: Move ftime symbol definition from _ftime.c
to crt-aliases.def.in"). It added ftime symbol only to crt-aliases.def.in
which is not used by api-ms-win-crt-* def files for UCRT builds.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-03-10 14:10:06 +02:00
Biswapriyo Nath
b025331084
headers: Use proper header file for std::nullptr_t
This fixes the following compiler error in gecko/gfx/angle.

include/wrl/client.h:275:45: error: use of undeclared identifier 'std'
  275 |         bool operator==(const ComPtr<T> &a, std::nullptr_t) throw()
      |                                             ^
include/wrl/client.h:281:25: error: use of undeclared identifier 'std'
  281 |         bool operator==(std::nullptr_t, const ComPtr<T> &a) throw()
      |                         ^

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-03-06 15:42:29 +08:00
Jacek Caban
2be9e0f319 Regenerate Makefile.in and configure 2025-03-04 20:20:22 +01:00
Jacek Caban
cd45d27575 crt: Always include load config in mingwex.
This is mandatory on ARM64EC and also required on AArch64 for ARM64X builds.
Instead of extending the existing logic, unify it by always including it in mingwex.

Fill CF Guard fields with zeroes when CF Guard is not enabled in CRT builds. This
leverages existing LLD load config validation warnings to signal potential issues
if the user enables CF Guard while using a CRT that was not built with it.

In practice, this means load config will always be present in output images when using
LLD. Since ld.bfd does not support load config, it remains unaffected.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-03-04 20:20:12 +01:00
Jacek Caban
2a5024409b include: Add missing float.h declarations.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-03-02 18:09:09 +01:00
Jøger Hansegård
99518b7fd9
Add missing comparison operators for Microsoft::WRL::ComPtr
The current MinGW implementation of Microsoft::WRL::ComPtr does not have
comparison operators. Attempting to compare two ComPtr instances will
implicitly convert the ComPtr to bool, and comparison is performed
against the resulting two bool values. This means that any two non-null
ComPtr instances compare equal.

This patch fixes this issue by adding the missing comparison operators.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-03-01 19:58:32 +08:00
Jacek Caban
d8daf57b63 crt: Remove unused FE_ROUNDING_MASK from pow.def.h.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-02-28 16:23:07 +01:00
Jacek Caban
b40b6a021d headers: Include float.h in fenv.h.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-02-28 16:23:07 +01:00
Jacek Caban
c771fdc8e7 fenv.h: Use unsigned long for fexcept_t on all targets.
This improves MSVC compatibility and unifies the code across different targets.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-02-28 16:23:07 +01:00
LIU Hao
08c5d55910
headers: Convert CRLF to LF
This is done with:

   dos2unix $(find mingw-w64-* -type f)

Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-28 23:02:09 +08:00
LIU Hao
b96006586e
headers/winhvplatformdefs: Allow WHV_SYNTHETIC_PROCESSOR_FEATURES::TbFlushHypercalls for ARM64
Reference: 90bb4a4e03/virtualization/api/hypervisor-platform/headers/WinHvPlatformDefs.h
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-28 21:59:41 +08:00
LIU Hao
f4f161453f
headers/winhvplatform: Update according to Micrsoft documentation
Reference: b68e659cbe/virtualization/api/hypervisor-platform/headers/WinHvPlatform.h
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-28 21:47:14 +08:00
LIU Hao
1f367c9e68
headers/winhvemulation: Update according to Micrsoft documentation
The types are updated in alignment with the referenced documentation. The
declarations of `WHvEmulatorCreateEmulator()` etc. seem to be gone, but
they probably should not have been. Along with previous changes to
winhvplatformdefs.h, they now reference `WHV_RUN_VP_EXIT_CONTEXT` which is
only available when targeting x86-64. Therefore, they are also so declared
only when targeting x86-64.

Reference: b68e659cbe/virtualization/api/hypervisor-platform/headers/WinHvEmulation.h
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-28 21:47:14 +08:00
LIU Hao
63ef400609
headers/winhvplatformdefs: Reorder declarations to match Microsoft documentation
To get a better overview about changes in this commit, use this command

   git show --color-moved --histogram <commit-SHA>

Reference: b68e659cbe/virtualization/api/hypervisor-platform/headers/WinHvPlatformDefs.h
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-28 21:47:14 +08:00
LIU Hao
2069938a55
headers/winhvplatformdefs: Update type definitions
Note: This code will not compile due to incorrect order of declarations,
which will be fixed in the next commit.

Reference: b68e659cbe/virtualization/api/hypervisor-platform/headers/WinHvPlatformDefs.h
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-28 21:47:14 +08:00
Martin Storsjö
e73e3d9833 crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:50:03 +02:00
Pali Rohár
694f7dfb30 crt: Remove DllEntryPoint from DLL builds
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 DllEntryPoint, GNU LD uses DllMainCRTStartup, MSVC link.exe
uses _DllMainCRTStartup.

The DLL application start function has same name DllMain.

Anyway, if the application is using own custom DLL entry point then it has
to pass appropriate compiler / linker parameters to omit inclusion of
standard library and/or startup files. Therefore removal of DllEntryPoint
should not cause big issues.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:49:27 +02:00
Pali Rohár
1a54872c3d crt: Remove custom declaration of _initterm() and DllMain() functions from crtdll.c
Function _initterm() is declared in corecrt_startup.h and DllMain() in process.h

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:49:27 +02:00
Pali Rohár
093079187c crt: Remove usage of SPECIAL_CRTEXE macro
This macro is only set but not used by any mingw-w64 file.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:49:27 +02:00
Pali Rohár
c8dce50086 crt: Remove usage of _DLL macro
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.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:49:27 +02:00
Pali Rohár
f0a79657fd crt: Remove usage of CRTDLL macro
This macro is used only on few places in .c files, not in .h files.
So remove its usage and dead code.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:49:24 +02:00
Pali Rohár
495f1f17b7 crt: Inline pre_c_init() into _CRT_INIT() in crtdll.c
This allows to remove the whole pre_c_init() function and registration of pcinit hook.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:47:55 +02:00
Pali Rohár
86de75f6cb crt: Inline __DllMainCRTStartup() into DllMainCRTStartup()
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 was removed in
commit e6ac7e4230c9 ("crt: Remove the vestigial gs_support.c").

So merge static __DllMainCRTStartup() function directly into entry point
function DllMainCRTStartup().

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:47:55 +02:00
Pali Rohár
fd411f6e8c crt: Move mingw-w64 / gcc DLL runtime code from __DllMainCRTStartup() to _CRT_INIT()
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 which prevents duplicate code execution.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:47:55 +02:00
Pali Rohár
91b83c2685 crt: Properly release __native_startup_lock on _CRT_INIT(DLL_PROCESS_ATTACH) failure
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:47:55 +02:00
Pali Rohár
87e16c3e9a crt: Guard negative __proc_attached value for DllMainCRTStartup(DLL_PROCESS_DETACH)
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:47:55 +02:00
Pali Rohár
14bffd38ca crt: Guard multiple _CRT_INIT(DLL_PROCESS_ATTACH) call for DLL builds
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 Visual C++ runtime is doing same thing.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:47:55 +02:00
Pali Rohár
4091765157 crt: Guard nested _CRT_INIT(DLL_PROCESS_DETACH) call for DLL builds
It is questionable which real issue can this guard detect or prevent,
but dll detach code from Visual C++ runtime is doing same thing.

And it makes sense that mingw-w64 would have compatible dll detach
logic with the Visual C++ dll detach code.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:47:30 +02:00
Pali Rohár
7d144f3a48 crt: Use BOOL type for boolean variable nested
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:47:04 +02:00
Pali Rohár
adeeff3c01 crt: Explicitly initialize __native_startup_state and __native_startup_lock variables to prevent C tentative definitions
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:47:04 +02:00
Pali Rohár
96c660c028 crt: Fix type of __native_startup_lock variable
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
InterlockedExchangePointer() call. But all current usage do explicit cast
to (volatile PVOID *) which hides all warnings.

Existing type:
volatile PVOID * = void * volatile *

Before this change:
typeof(&__native_startup_lock) = void volatile **

After this change:
typeof(&__native_startup_lock) = void * volatile *

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-28 13:47:04 +02:00
LIU Hao
135d3e8c94
crt: Regenerate Makefile.in
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-28 10:22:52 +08:00
LIU Hao
343bce7b02
Revert "winpthreads: move SIG_* constants from pthread.h to pthread_signal.h"
This reverts commit 535db6fcc2e5dfcfb0541a57e74ad926f6b3def6.

In libiberty there's code which, if `SIG_SETMASK` is called, attempts to call
`sigprocmask()`, which does not exist on Windows. Therefore these macros can't
exist in signal.h.

Reference: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libiberty/sigsetmask.c;h=f7a24246d1fdb15eacb414c35a6cdd98d95e6c4b;hb=HEAD
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 11:27:51 +08:00
LIU Hao
60306a9d5a
headers/wchar: Include corecrt_wctype.h and deduplicate code
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:24:57 +08:00
LIU Hao
d946312a17
headers/ctype: Remove useless inclusion of crtdefs.h
Co-authored-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:24:56 +08:00
LIU Hao
ae6c077e7f
headers/ctype: Include corecrt_wctype.h and deduplicate code
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:24:56 +08:00
LIU Hao
87f78719cf
headers/corecrt_wctype: Include corecrt.h instead of crtdefs.h
This commit also removes macros, types and pragmas which are either defined
indirectly or unused.

Co-authored-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:24:56 +08:00
LIU Hao
0a703a3845
headers/{corecrt_wctype,wctype}: Split wctype.h
The changes can be examined with `git show --color-moved`.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:24:56 +08:00
LIU Hao
e5bb1de106
headers/wctype: Copy two blocks from ctype.h
Inline functions are deleted, as in UCRT headers.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:24:56 +08:00
LIU Hao
ff5a36b25d
headers/tchar: Add _istblank and _istblank_l
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:24:56 +08:00
LIU Hao
19224ec9a1
headers/ctype: Reorder function declarations
The changes can be examined with `git show --color-moved`.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:24:56 +08:00
LIU Hao
7450e231f6
headers/ctype: Declare isblank-family functions
Previously, these were only declared for C99 or C++. To avoid complication in
tchar.h, they are now declared unconditionally.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:24:56 +08:00
LIU Hao
3aa4a65608
crt/{is{,w}blank,_is{,w}blank_l}: Define correct macros, and include correct headers
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:24:56 +08:00
LIU Hao
0f9dfcb873
crt: Implement is{,w}blank_l() for MSVCR{T,80,90,100,110}
For consistency with MSVCR120, all these functions are marked as dllimport.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:24:56 +08:00
Kirill Makurin
f515c4905f
winpthreads: remove unused macro USE_SEM_CriticalSection_SpinCount from semaphore.h
Signed-off-by: Kirill Makurin <maiddaisuki@outlook.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:14:23 +08:00
Kirill Makurin
535db6fcc2
winpthreads: move SIG_* constants from pthread.h to pthread_signal.h
Explicitly include pthread_signal.h from pthread.h when compiling with MSVC.

Signed-off-by: Kirill Makurin <maiddaisuki@outlook.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:14:23 +08:00
Kirill Makurin
14292ce799
winpthreads: remove old typedef of pthread_t from pthread.h
Signed-off-by: Kirill Makurin <maiddaisuki@outlook.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:14:23 +08:00
LIU Hao
4696986c30
crt/fesetexceptflag: Fix MXCSR operation
It should set the exception bits, rather than the exception mask bits.
Code on line 38-41 does the correct operation to the x87 status bits.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-26 09:11:30 +08:00
LIU Hao
ef051be563
crt: Regenerate Makefile.in
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-25 10:02:47 +08:00
Pali Rohár
6f5d076f22
crt: Provide __iswcsymf and __iswcsym for all CRT import libraries
Symbols __iswcsymf and __iswcsym are available in msvcr80+ and UCRT.
They are not available in msvcrt.dll.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-02-25 10:00:29 +08:00