[Mingw-w64-public] [PATCH 02/11] crt: Make ucrt_fwprintf consistent with the other ucrt_* files

2025-03-20 Thread Martin Storsjö
All the other files directly call the right __stdio_common function rather than calling the next level layered function (e.g. printf->vprintf->vfprintf). Signed-off-by: Martin Storsjö --- mingw-w64-crt/stdio/ucrt_fwprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ming

[Mingw-w64-public] [PATCH 10/10] headers: Add support for -D_TIME_BITS=64

2025-03-20 Thread Pali Rohár
Currently all 32-bit non-UCRT builds are forced to use time_t type as 32-bit and also all time_t functions in 32-bit form. With this change, any msvcrt.dll based 32-bit application can use 64-bit time_t functions by defining -D_TIME_BITS=64 flag during compilation. Flag -D_TIME_BITS=64 is recogni

[Mingw-w64-public] [PATCH] Revert "ucrtbase: Make sure that compat symbols aren't autoexported"

2025-03-20 Thread Martin Storsjö
This reverts commit 91459ac35276522b0e4405c76795d91822bb395a. That commit was a workaround for older binutils or LLD versions, that would otherwise autoexport symbols from the CRT libraries. Since 9d9c67b06c1bf4c4550e3de0eb575c2bfbe96df9 in binutils (in 2017), binutils does exclude "libmsvcrt", "

[Mingw-w64-public] [PATCH 08/10] headers: Fix declaration of POSIX stat/fstat and LFS stat64/fstat64 functions

2025-03-20 Thread Pali Rohár
Move LFS defines of stat64/fstat64 from _mingw_stat64.h to sys/stat.h. Move struct stat from _mingw_stat64.h to sys/stat.h. Fix definition of POSIX struct stat to follow both _FILE_OFFSET_BITS and _USE_32BIT_TIME_T settings. Fix declaration of POSIX stat(), fstat() and mingw-w64 wstat() functions

Re: [Mingw-w64-public] [PATCH 00/11] UCRT stdio option handling, __ms_ prefixed functions

2025-03-20 Thread Pali Rohár
On Thursday 20 March 2025 23:00:54 Martin Storsjö wrote: > And with that in mind, I'm actually wondering if we should revert > 581532b8e49a0e10cbdfe2332a8c1d61ff3d6820 regardless of this patchset? I'm > actually less convinced that we want to have this distinction. If we have > printf() and wprintf

Re: [Mingw-w64-public] [PATCH 00/11] UCRT stdio option handling, __ms_ prefixed functions

2025-03-20 Thread Martin Storsjö
On Thu, 20 Mar 2025, Pali Rohár wrote: On Thursday 20 March 2025 21:57:42 Martin Storsjö wrote: On Thu, 20 Mar 2025, Pali Rohár wrote: For example in -std=c99 mode we should rather follow C99 standard and hence %s in wprintf should take char*. So far, we have decided to match MSVC in this a

[Mingw-w64-public] [PATCH 2/5] crt: Provide _aligned_* functions

2025-03-20 Thread Pali Rohár
Functions _aligned_free(), _aligned_malloc(), _aligned_offset_malloc(), _aligned_offset_realloc() and _aligned_realloc() are available since msvcr70.dll. For older CRT import libraries provide emulation via mingw functions __mingw_aligned_free(), __mingw_aligned_malloc(), __mingw_aligned_offset_mal

[Mingw-w64-public] [PATCH 5/5] crt: Provide _aligned_msize function for all CRT import libraries

2025-03-20 Thread Pali Rohár
Function _aligned_msize() is available only in msvcr80+ and UCRT. It is not available in msvcrt.dll system os library. --- mingw-w64-crt/Makefile.am | 2 ++ mingw-w64-crt/misc/_aligned_msize.c | 13 + mingw-w64-headers/crt/crtdbg.h | 2 -- mingw-w64-headers/crt/malloc.

[Mingw-w64-public] [PATCH 4/5] crt: Implement __mingw_aligned_msize() function

2025-03-20 Thread Pali Rohár
It mimics msvc _aligned_msize() function. --- mingw-w64-crt/misc/mingw-aligned-malloc.c | 23 +++ mingw-w64-headers/crt/malloc.h| 1 + 2 files changed, 24 insertions(+) diff --git a/mingw-w64-crt/misc/mingw-aligned-malloc.c b/mingw-w64-crt/misc/mingw-aligned-mall

[Mingw-w64-public] [PATCH 0/5] Improve _aligned_* function support

2025-03-20 Thread Pali Rohár
This patch series provides all _aligned_* functions for all CRT import libs. Pali Rohár (5): headers: Add missing declaration for __mingw_aligned_offset_malloc() crt: Provide _aligned_* functions crt: Provide *_recalloc functions crt: Implement __mingw_aligned_msize() function crt: Provi

[Mingw-w64-public] [PATCH 09/10] crt: Provide emulation of _time64 function

2025-03-20 Thread Pali Rohár
Function _time64 is avaulable since msvcr70.dll. For older msvcrt versions provide emulation via WinAPI GetSystemTime() function which is available on all Windows versions and returns native value in SYSTEMTIME format. --- mingw-w64-crt/Makefile.am | 2 ++ mingw-w64-crt/lib-common/ms

[Mingw-w64-public] [PATCH 01/10] crt: Provide emulation of _fstat64, _stat64 and _wstat64 functions

2025-03-20 Thread Pali Rohár
These functions are available since msvcr70.dll. For older msvcrt versions provide emulation via _fstat32(), _stat32() and _wstat32() functions. These functions have only truncated 32-bit file size and timestamp support. Real 64-bit non-truncated file size and timestamp information is retrieved via

[Mingw-w64-public] [PATCH 06/10] headers: Add missing _CRTIMP for _fstat64i32/_stat64i32/_wstat64i32 functions

2025-03-20 Thread Pali Rohár
All other _*stat* functions are already marked with _CRTIMP, so add it also for missing 3 functions. --- mingw-w64-headers/crt/sys/stat.h | 6 +++--- mingw-w64-headers/crt/wchar.h| 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mingw-w64-headers/crt/sys/stat.h b/mingw-w6

[Mingw-w64-public] [PATCH 02/10] crt: Fix mingw-w64 emulation of _fstat64i32, _stat64i32 and _wstat64i32 functions

2025-03-20 Thread Pali Rohár
All 64-bit CRT import libraries already provides _fstat64i32, _stat64i32 and _wstat64i32 function symbols. These symbols are either directly exported from 64-bit CRT DLL library or def file contains alias to other ABI compatible symbols (_fstat, _stat and _wstat). Also all these functions _fstat64

[Mingw-w64-public] [PATCH 03/10] crt: Provide emulation of _fstat32i64, _stat32i64 and _wstat32i64 functions

2025-03-20 Thread Pali Rohár
Functions _fstat32i64 (alias of _fstati64), _stat32i64 (alias of _stati64) and _wstat32i64 (alias of _wstati64) are available since msvcrt40.dll. These functions returns 64-bit st_size and 32-bit file timestamps. For pre-msvcrt40 CRT import libraries provides mingw-w64 emulation of those functions

Re: [Mingw-w64-public] mingw-w64 loadcfg.S compile error

2025-03-20 Thread Pali Rohár
On Thursday 20 March 2025 21:44:22 Jacek Caban wrote: > On 20.03.2025 20:29, Pali Rohár wrote: > > I suspect that the change is related to recent commit cd45d275754e > > ("crt: Always include load config in mingwex."). > > > > Jacek, could you look at it? > > > > For the record, my old gcc, ld an

Re: [Mingw-w64-public] mingw-w64 new compile warning: initialized and declared extern

2025-03-20 Thread Jacek Caban
On 20.03.2025 21:05, Martin Storsjö wrote: On Thu, 20 Mar 2025, Pali Rohár wrote: Hello, I started getting new compile warnings during compilation of mingw-w64 runtime. In file included from math/modfl.c:6: .../mingw-w64-headers/crt/fenv.h:64:39: warning: ‘__mingw_fe_dfl_env’ initialized and

Re: [Mingw-w64-public] [PATCH 07/11] crt, headers: Convert the UCRT *wprintf functions to non-inline

2025-03-20 Thread Jacek Caban
On 20.03.2025 18:54, Martin Storsjö wrote: +int __cdecl (*__MINGW_IMP_SYMBOL(snwprintf))(wchar_t *__restrict__, size_t, const wchar_t *__restrict__, ...) = snwprintf; Do we need those |__imp_| symbols in these files? We don’t declare them as |dllimport| in headers, and since they were previo

Re: [Mingw-w64-public] mingw-w64 new compile warning: initialized and declared extern

2025-03-20 Thread Martin Storsjö
On Thu, 20 Mar 2025, Pali Rohár wrote: Hello, I started getting new compile warnings during compilation of mingw-w64 runtime. In file included from math/modfl.c:6: .../mingw-w64-headers/crt/fenv.h:64:39: warning: ‘__mingw_fe_dfl_env’ initialized and declared ‘extern’ extern const __MINGW_SELEC

Re: [Mingw-w64-public] [PATCH 00/11] UCRT stdio option handling, __ms_ prefixed functions

2025-03-20 Thread Martin Storsjö
On Thu, 20 Mar 2025, Pali Rohár wrote: For example in -std=c99 mode we should rather follow C99 standard and hence %s in wprintf should take char*. So far, we have decided to match MSVC in this aspect. For MSVC 2015 CTP1 they first announced that they would change MSVC to default to the C99

[Mingw-w64-public] mingw-w64 loadcfg.S compile error

2025-03-20 Thread Pali Rohár
Hello, I cannot compile mingw-w64 with my older gcc setup. It is failing on following error: i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -m32 -masm=att -I./include "-I/usr/local/include" -I.../mingw-w64/mingw-w64-headers/crt/ -I.../mingw-w64/mingw-w64-headers/include/ -march=i486 -Os -g -MT crt/

Re: [Mingw-w64-public] [PATCH 00/11] UCRT stdio option handling, __ms_ prefixed functions

2025-03-20 Thread Pali Rohár
Hello, I'm not sure if it is correct to alias every one __ms_ and non-ms ucrt printf/scanf function. For example in -std=c99 mode we should rather follow C99 standard and hence %s in wprintf should take char*. But __ms_wprintf should take wchar_t* (independently of -std= option) as this is on wha

[Mingw-w64-public] [PATCH 10/11] headers: Redirect __ms_ back to plain for UCRT

2025-03-20 Thread Martin Storsjö
In principle, we could maybe also do this for CRTs other than UCRT; there we currently define these aliases in def files. This fixes breakage after 581532b8e49a0e10cbdfe2332a8c1d61ff3d6820, noted and discussed at https://github.com/git-for-windows/build-extra/commit/b1b6eb5c5d78c4d8da53c4daa6aa6cf

[Mingw-w64-public] [PATCH 11/11] crt: Remove the separate UCRT __ms_fprintf function

2025-03-20 Thread Martin Storsjö
We don't strictly need it, we can redirect to the right function using __MINGW_ASM_CALL() in the headers - this function was only added in c9eca28decb3aa5213fe22ab1f9883df91d79806 to fix the most immediate breakage after 581532b8e49a0e10cbdfe2332a8c1d61ff3d6820. Note that we do need to keep ucrt_m

[Mingw-w64-public] [PATCH 08/11] crt, headers: Convert the UCRT *wscanf functions to non-inline

2025-03-20 Thread Martin Storsjö
Signed-off-by: Martin Storsjö --- mingw-w64-crt/Makefile.am | 6 mingw-w64-crt/stdio/ucrt_fwscanf.c | 19 ++ mingw-w64-crt/stdio/ucrt_swscanf.c | 20 +++ mingw-w64-crt/stdio/ucrt_vfwscanf.c | 14 mingw-w64-crt/stdio/ucrt_vswscanf.c | 14 mingw-w

[Mingw-w64-public] [PATCH 00/11] UCRT stdio option handling, __ms_ prefixed functions

2025-03-20 Thread Martin Storsjö
Hi, This is a series of patches, which essentially does three different things. The ultimate target of the series is to fix a regression; in 581532b8e49a0e10cbdfe2332a8c1d61ff3d6820, tchar.h started referencing __ms_ prefixed symbols for many functions, even if UCRT didn't actually provide those

[Mingw-w64-public] [PATCH 09/11] headers: Declare __ms_vsscanf, __ms_vscanf, __ms_vfscanf, __ms_vswscanf, __ms_vwscanf, __ms_vfwscanf, __ms_snprintf, __ms_vsnprintf, __ms_snwprintf and __ms_vsnwprintf

2025-03-20 Thread Martin Storsjö
From: Pali Rohár Declaration of all these functions is currently hidden inside !_UCRT block. Move them outside of the block, so they are always visible. Signed-off-by: Martin Storsjö --- mingw-w64-headers/crt/stdio.h | 45 +++ mingw-w64-headers/crt/wchar.h | 16

Re: [Mingw-w64-public] stat, _stat, and _stat64i32 issues (was: dirent changes)

2025-03-20 Thread Pali Rohár
On Wednesday 12 March 2025 16:33:42 Lasse Collin wrote: > On 2025-03-09 Pali Rohár wrote: > > On Friday 07 March 2025 20:31:09 Lasse Collin wrote: > > > The commit 45bf2cca702b from 2009 added memset calls to zero the > > > stat buffer on failure. That seems unncessary, but the commit > > > message

Re: [Mingw-w64-public] [PATCH] crt: Remove ad-hoc fpreset == _fpreset aliases from individual .def files

2025-03-20 Thread Jacek Caban
On 20.03.2025 17:47, Pali Rohár wrote: On Monday 17 March 2025 23:47:19 Pali Rohár wrote: On Monday 17 March 2025 23:44:25 Jacek Caban wrote: On 17.03.2025 21:35, Pali Rohár wrote: Enable underscored fpreset alias for ARM targets in crt-aliases.def.in include file, which is automatically inclu

Re: [Mingw-w64-public] [PATCH] crt: Remove ad-hoc fpreset == _fpreset aliases from individual .def files

2025-03-20 Thread Pali Rohár
On Monday 17 March 2025 23:47:19 Pali Rohár wrote: > On Monday 17 March 2025 23:44:25 Jacek Caban wrote: > > On 17.03.2025 21:35, Pali Rohár wrote: > > > Enable underscored fpreset alias for ARM targets in crt-aliases.def.in > > > include file, which is automatically included into all msvcr*.def.in