crt: Define fseeko64 symbol as alias to _fseeki64 mingw-w64 implementation of fseeko64() and _fseeki64() functions in files mingw-w64-crt/stdio/_fseeki64.c and mingw-w64-crt/stdio/fseeko64.c are exactly same. Also both fseeko64() and _fseeki64() functions have C fseek() ABI with 64-bit offset type. So remove the mingw-w64 fseeko64 implementation and define fseeko64 symbol as an alias to the _fseeki64 symbol. For msvcr80+ define it in def include file crt-aliases.def.in and for other implementations define it in the mingw-w64-crt/stdio/_fseeki64.c file. This change allows to use native msvcr80+ / UCRT implementation of _fseeki64() function for the POSIX fseeko64() instead of statically linking the mingw-w64 implementation. Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index fab93c1..8ee5b8c 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am
@@ -1126,7 +1126,7 @@ stdio/strtok_r.c \ stdio/_Exit.c stdio/_findfirst64i32.c stdio/_findnext64i32.c stdio/_wfindfirst64i32.c stdio/_wfindnext64i32.c \ stdio/asprintf.c \ - stdio/fopen64.c stdio/fseeko64.c \ + stdio/fopen64.c \ stdio/ftello64.c stdio/ftruncate64.c stdio/lltoa.c stdio/lltow.c stdio/lseek64.c \ stdio/__mingw_fix_stat.h stdio/__mingw_fix_stat_finish.c \ stdio/__mingw_fix_stat_path.c stdio/__mingw_fix_wstat_path.c \
diff --git a/mingw-w64-crt/def-include/crt-aliases.def.in b/mingw-w64-crt/def-include/crt-aliases.def.in index 25f5b87..b30e8ea 100644 --- a/mingw-w64-crt/def-include/crt-aliases.def.in +++ b/mingw-w64-crt/def-include/crt-aliases.def.in
@@ -319,6 +319,9 @@ #else fstat64 == _fstat64 #endif +#ifndef FIXED_SIZE_SYMBOLS +fseeko64 == _fseeki64 +#endif ; This is list of symbol aliases for GNU functions which are not part of POSIX or ISO C strcasecmp == _stricmp
diff --git a/mingw-w64-crt/lib-common/api-ms-win-crt-stdio-l1-1-0.def b/mingw-w64-crt/lib-common/api-ms-win-crt-stdio-l1-1-0.def index abdcb82..38bd1aa 100644 --- a/mingw-w64-crt/lib-common/api-ms-win-crt-stdio-l1-1-0.def +++ b/mingw-w64-crt/lib-common/api-ms-win-crt-stdio-l1-1-0.def
@@ -63,6 +63,7 @@ _fread_nolock_s _fseek_nolock _fseeki64 +fseeko64 == _fseeki64 _fseeki64_nolock _fsopen _ftell_nolock
diff --git a/mingw-w64-crt/stdio/_fseeki64.c b/mingw-w64-crt/stdio/_fseeki64.c index 3ec4ccb..6881930 100644 --- a/mingw-w64-crt/stdio/_fseeki64.c +++ b/mingw-w64-crt/stdio/_fseeki64.c
@@ -38,3 +38,6 @@ #define ARGS FILE *stream, __int64 offset, int whence #define CALL stream, offset, whence #include "msvcrt_or_emu_glue.h" + +int __attribute__ ((alias ("_fseeki64"))) __cdecl fseeko64(FILE *stream, _off64_t offset, int whence); +extern int __attribute__ ((alias (__MINGW64_STRINGIFY(__MINGW_IMP_SYMBOL(_fseeki64))))) (__cdecl *__MINGW_IMP_SYMBOL(fseeko64))(FILE *stream, _off64_t offset, int whence);
diff --git a/mingw-w64-crt/stdio/fseeko64.c b/mingw-w64-crt/stdio/fseeko64.c deleted file mode 100644 index 3161634..0000000 --- a/mingw-w64-crt/stdio/fseeko64.c +++ /dev/null
@@ -1,34 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#include <stdio.h> -#include <io.h> -#include <errno.h> - -int fseeko64 (FILE* stream, _off64_t offset, int whence) -{ - fpos_t pos; - if (whence == SEEK_CUR) - { - /* If stream is invalid, fgetpos sets errno. */ - if (fgetpos (stream, &pos)) - return (-1); - pos += (fpos_t) offset; - } - else if (whence == SEEK_END) - { - /* If writing, we need to flush before getting file length. */ - fflush (stream); - pos = (fpos_t) (_filelengthi64 (_fileno (stream)) + offset); - } - else if (whence == SEEK_SET) - pos = (fpos_t) offset; - else - { - errno = EINVAL; - return (-1); - } - return fsetpos (stream, &pos); -}