crt: Fix ABI of mingw-w64 emulation of POSIX stat* functions

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 correctly fills either 32-bit or 64-bit st_* values.

To follow existing msvcrt/UCRT symbol naming convention, provide 4 symbols
for stat function: stat32, stat32i64, stat64i32 and stat64. And also
provide stat symbol as alias to stat32 on 32-bit systems or to stat64i32 on
64-bit systems. Same as existing msvcrt/UCRT ABI for _stat function.

Note that stat64 function is part of the Large File Specification but it
does not describe if the st_atime/st_mtime/st_ctime should be also 64-bit
or only 32-bit. msvcrt/UCRT ABI expects them to be also 64-bit.

Do same for wstat symbol, wide UTF-16 variant of stat.

At the same time remove old and broken stat and wstat symbols, they are
replaced by the new alias.

Extract existing and duplicated function _mingw_no_trailing_slash into new
file and rename it to __mingw_fix_stat_path which better describe its
purpose. Do same for wide variant __mingw_fix_wstat_path. These two
functions have some known bugs and will be fixed later.

This change is not fixing bugs in these functions, it is only fixing the
API/ABI incompatibility which comes from the _FILE_OFFSET_BITS and
_USE_32BIT_TIME_T settings.

Signed-off-by: Martin Storsjö <martin@martin.st>
15 files changed