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 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.
---
mingw-w64-crt/Makefile.am | 2 +-
mingw-w64-crt/def-include/crt-aliases.def.in | 3 ++
.../api-ms-win-crt-stdio-l1-1-0.def | 1 +
mingw-w64-crt/stdio/_fseeki64.c | 3 ++
mingw-w64-crt/stdio/fseeko64.c | 34 -------------------
5 files changed, 8 insertions(+), 35 deletions(-)
delete mode 100644 mingw-w64-crt/stdio/fseeko64.c
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index a6d45d93419e..d6576bb7320a 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -1113,7 +1113,7 @@ src_libmingwex=\
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_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 25f5b87010e0..b30e8ea64911 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 @@ fstat64 == _fstat64
#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 abdcb8224c7c..38bd1aa819f4 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
_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 3ec4ccb3a392..6881930b0698 100644
--- a/mingw-w64-crt/stdio/_fseeki64.c
+++ b/mingw-w64-crt/stdio/_fseeki64.c
@@ -38,3 +38,6 @@ static int __cdecl emu__fseeki64(FILE *stream, __int64
offset, int whence)
#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 316163497b78..000000000000
--- 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);
-}
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public