[Mingw-w64-public] [PATCH v2 00/13] Fix stat functions

2025-04-13 Thread Pali Rohár
This patch series is fixing stat functions as was discussed in the long email thread "stat, _stat, and _stat64i32 issues (was: dirent changes)". I have not included in this patch series Lasse's followup changes. In v2 are fixed also ftw and nftw functions which directly calls stat. And there are l

[Mingw-w64-public] [PATCH v2 11/13] crt: Fix POSIX stat() with 32-bit st_size for pre-msvcr100 build

2025-04-13 Thread Pali Rohár
For POSIX stat compatibility, it is not possible to use msvcrt _stat32() or _stat64i32() from crtdll.dll - msvcr100.dll CRT libraries as their implementations do not signal EOVERFLOW error when file size does not fit into the stat's st_size field. Signalling EOVERFLOW is required for POSIX compatib

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

2025-04-13 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

[Mingw-w64-public] [PATCH v2 08/13] crt: Fix ABI of POSIX ftw() and nftw() functions

2025-04-13 Thread Pali Rohár
There are 4 POSIX stat functions (stat32, stat32i64, stat64, stat64i32) which differs in the stat structure point size. And there is additional stat symbol which alias to one of those based on the _FILE_OFFSET_BITS and _USE_32BIT_TIME_T settings. As POSIX ftw() and nftw() functions takes also stru

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

2025-04-13 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 v2 09/13] headers: Fix declaration of POSIX stat/fstat and LFS stat64/fstat64 functions

2025-04-13 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

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

2025-04-13 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 v2 07/13] crt: Fix ABI of mingw-w64 emulation of POSIX stat* functions

2025-04-13 Thread Pali Rohár
POSIX struct stat has 4 variants in mingw-w64 based on the macros _FILE_OFFSET_BITS and _USE_32BIT_TIME_T settings. st_size can be either 32-bit or 64-bit, and st_atime/st_mtime/st_ctime can also be 32-bit or 64-bit. So for each ABI of struct stat there has to be separate POSIX stat function which

[Mingw-w64-public] [PATCH v2 12/13] crt: Provide emulation of _time64 function

2025-04-13 Thread Pali Rohár
Function _time64 is available 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 v2 10/13] headers: Fix declaration of POSIX ftw/nftw functions

2025-04-13 Thread Pali Rohár
Fix declaration of POSIX ftw() and nftw() functions to follow all combinations of _FILE_OFFSET_BITS and _USE_32BIT_TIME_T settings. Use __MINGW_ASM_CALL as a redirection to correct ABI symbol. Do not declare these two functions when building the mingw-w64 runtime itself as it is not clear which of

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

2025-04-13 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 in all pre-msvcr100 CRT libraries provides only truncated 32-bit file size and invalid value -1 as timestamp. The real 64-bit non-truncat

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

2025-04-13 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 v2 04/13] headers: Remove broken inline stat() and fstat() functions

2025-04-13 Thread Pali Rohár
Correct versions are provided by non-inline variants. To prevent code duplication and maintenance, remove those inline definitions completely instead of fixing them. --- mingw-w64-headers/crt/sys/stat.h | 84 1 file changed, 84 deletions(-) diff --git a/mingw-w64-

Re: [Mingw-w64-public] stat, _stat, and _stat64i32 issues

2025-04-13 Thread Pali Rohár
On Tuesday 08 April 2025 19:23:37 Lasse Collin wrote: > On 2025-04-06 Pali Rohár wrote: > > On Saturday 29 March 2025 18:56:56 Lasse Collin wrote: > > > On 2025-03-29 Pali Rohár wrote: > > > > Problem is that you cannot define _USE_32BIT_TIME_T on UCRT > > > > builds. There are header ifdef check

Re: [Mingw-w64-public] stat, _stat, and _stat64i32 issues

2025-04-13 Thread Pali Rohár
On Saturday 22 March 2025 15:35:48 Lasse Collin wrote: > Things I noticed about your patches but I didn't make any changes: > > - With MSVCRT, _stat32 sets timestamps to -1 if the time doesn't fit > into 32-bit time_t. The 32i64 wrappers truncate the timestamps > instead. Maybe this does