On Sun, 13 Apr 2025, Pali Rohár wrote:
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 to
follow all combinations of _FILE_OFFSET_BITS and _USE_32BIT_TIME_T settings.
Declare fstat() as a function instead of macro. Define it as alias via
__MINGW_ASM_CALL to one of the CRT _fstat* function based on
_FILE_OFFSET_BITS and _USE_32BIT_TIME_T settings.
In the same way declare stat() and wstat() as functions. But as alias to
one of the mingw-w64 (w)stat* function. This is needed because msvcrt
_(w)stat* functions have issue with trailing slash and requires mingw-w64
wrapper for POSIX compatibility.
Additionally define struct stat64 for LFS functions stat64(), fstat64() and
mingw-w64 function wstat64(). And again declare them as a functions instead
of macro.
Keyword stat has to be declared as a function, not as a macro because it
would override effect of struct stat.
Do not declare these stat/fstat/wstat functions when building the mingw-w64
runtime itself as it is not clear which of those stat[size] / fstat[size] /
wstat[size] symbol should be used. Instead the mingw-w64 source file should
call the appropriate ABI compatible *stat[size] function with corresponding
ABI compatible struct _stat[size].
---
mingw-w64-crt/misc/crtdll_fstat.c | 1 +
mingw-w64-crt/misc/ftw.c | 2 -
mingw-w64-crt/misc/ftw64.c | 2 +-
mingw-w64-crt/stdio/_fstat64.c | 5 +-
mingw-w64-crt/stdio/stat64.c | 8 +--
mingw-w64-crt/stdio/wstat64.c | 7 +--
mingw-w64-headers/crt/_mingw_stat64.h | 23 +-------
mingw-w64-headers/crt/sys/stat.h | 80 ++++++++++++++++++++-------
8 files changed, 72 insertions(+), 56 deletions(-)
Compiling fails for the ftw functions at this patch; this is only fixed by
the next patch.
I presume this is hard to fix in other ways than just squashing the two
patches, and I guess it's good to keep them separate for separate
explanations in the commit messages, so I guess we can tolerate if in this
case, but ideally it should be possible to compile things at any point.
// Martin
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public