After running more tests I figured out that fgetpos64/fsetpos64 needs
additional alias in UCRT def file (as those api-*.def do not use
crt-aliases.def.in).
Fixup for this commit is below:
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 cdfc2362b6c1..d23469ac26ab 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
@@ -155,6 +155,7 @@ ferror
fflush
fgetc
fgetpos
+fgetpos64 == fgetpos
fgets
fgetwc
fgetws
@@ -170,6 +171,7 @@ freopen
freopen_s
fseek
fsetpos
+fsetpos64 == fsetpos
ftell
fwrite
getc
On Sunday 16 June 2024 16:40:21 Pali Rohár wrote:
> Functions fgetpos64() and fsetpos64() are just aliases for functions
> fgetpos() and fsetpos() as they are already using 64-bit fpos_t type.
>
> Most aliased functions are defined in crt-aliases.def.in file. Do same also
> for fgetpos64() and fsetpos64() functions by moving them from individual C
> files stdio/fgetpos64.c and stdio/fsetpos64.c.
>
> Libraries which do not have real fgetpos() and fsetpos() have aliases
> defined in the same file were are defined compatibility wrappers.
> ---
> mingw-w64-crt/Makefile.am | 4 ++--
> mingw-w64-crt/def-include/crt-aliases.def.in | 7 +++++++
> mingw-w64-crt/lib32/crtdll.def.in | 1 +
> mingw-w64-crt/lib32/msvcrt10.def.in | 1 +
> mingw-w64-crt/lib32/msvcrt20.def.in | 1 +
> mingw-w64-crt/stdio/fgetpos.c | 3 +++
> mingw-w64-crt/stdio/fgetpos64.c | 5 -----
> mingw-w64-crt/stdio/fsetpos.c | 3 +++
> mingw-w64-crt/stdio/fsetpos64.c | 5 -----
> 9 files changed, 18 insertions(+), 12 deletions(-)
> delete mode 100644 mingw-w64-crt/stdio/fgetpos64.c
> delete mode 100644 mingw-w64-crt/stdio/fsetpos64.c
>
> diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
> index b2caafc3d475..384541c5833b 100644
> --- a/mingw-w64-crt/Makefile.am
> +++ b/mingw-w64-crt/Makefile.am
> @@ -847,8 +847,8 @@ src_libmingwex=\
> stdio/_Exit.c stdio/_findfirst64i32.c stdio/_findnext64i32.c \
> stdio/_ftime.c \
> stdio/_stat.c stdio/_stat64i32.c
> stdio/_wfindfirst64i32.c stdio/_wfindnext64i32.c \
> - stdio/_wstat.c stdio/_wstat64i32.c stdio/asprintf.c
> stdio/fgetpos64.c \
> - stdio/fopen64.c stdio/fseeko32.c stdio/fseeko64.c
> stdio/fsetpos64.c stdio/ftello.c \
> + stdio/_wstat.c stdio/_wstat64i32.c stdio/asprintf.c \
> + stdio/fopen64.c stdio/fseeko32.c stdio/fseeko64.c
> stdio/ftello.c \
> stdio/ftello64.c stdio/ftruncate64.c stdio/lltoa.c
> stdio/lltow.c stdio/lseek64.c \
> stdio/mingw_fprintf.c stdio/mingw_fprintfw.c stdio/mingw_fscanf.c
> stdio/mingw_fwscanf.c stdio/mingw_pformat.c \
> stdio/mingw_pformatw.c stdio/mingw_printf.c stdio/mingw_printfw.c
> stdio/mingw_scanf.c stdio/mingw_snprintf.c \
> diff --git a/mingw-w64-crt/def-include/crt-aliases.def.in
> b/mingw-w64-crt/def-include/crt-aliases.def.in
> index 885563da1d26..e23bd9348644 100644
> --- a/mingw-w64-crt/def-include/crt-aliases.def.in
> +++ b/mingw-w64-crt/def-include/crt-aliases.def.in
> @@ -240,6 +240,13 @@ ADD_UNDERSCORE(pclose)
> ADD_UNDERSCORE(popen)
> ; ADD_UNDERSCORE(scalb)
>
> +; This is list of symbol aliases for Large File Specification (extension to
> Single UNIX Specification)
> +#ifndef NO_FPOS64_ALIASES
> +; fgetpos and fsetpos are already 64-bit
> +fgetpos64 == fgetpos
> +fsetpos64 == fsetpos
> +#endif
> +
> ; This is list of symbol aliases for GNU functions which are not part of
> POSIX or ISO C
> strcasecmp == _stricmp
> strncasecmp == _strnicmp
> diff --git a/mingw-w64-crt/lib32/crtdll.def.in
> b/mingw-w64-crt/lib32/crtdll.def.in
> index 29b99dfb1f83..d1074334b05d 100644
> --- a/mingw-w64-crt/lib32/crtdll.def.in
> +++ b/mingw-w64-crt/lib32/crtdll.def.in
> @@ -628,5 +628,6 @@ _ultow
> #define FIXED_SIZE_SYMBOLS
> #define NO_WIDE_FIXED_SIZE
> #define NO_I64_FIXED_SIZE
> +#define NO_FPOS64_ALIASES
> #define NO_STRCMPI_ALIAS
> #include "crt-aliases.def.in"
> diff --git a/mingw-w64-crt/lib32/msvcrt10.def.in
> b/mingw-w64-crt/lib32/msvcrt10.def.in
> index a2b979611078..258b38ce9e73 100644
> --- a/mingw-w64-crt/lib32/msvcrt10.def.in
> +++ b/mingw-w64-crt/lib32/msvcrt10.def.in
> @@ -1298,5 +1298,6 @@ wscanf
> #define FIXED_SIZE_SYMBOLS
> #define NO_WIDE_FIXED_SIZE
> #define NO_I64_FIXED_SIZE
> +#define NO_FPOS64_ALIASES
> #define NO_STRCMPI_ALIAS
> #include "crt-aliases.def.in"
> diff --git a/mingw-w64-crt/lib32/msvcrt20.def.in
> b/mingw-w64-crt/lib32/msvcrt20.def.in
> index 83a3be67debd..f3b5434d3f7d 100644
> --- a/mingw-w64-crt/lib32/msvcrt20.def.in
> +++ b/mingw-w64-crt/lib32/msvcrt20.def.in
> @@ -1579,6 +1579,7 @@ _safe_fprem1
> #define PRE_C95_SWPRINTF
> #define FIXED_SIZE_SYMBOLS
> #define NO_I64_FIXED_SIZE
> +#define NO_FPOS64_ALIASES
> #define NO_STRCMPI_ALIAS
> #define WITH_IOB_FUNC_ALIAS
> #include "crt-aliases.def.in"
> diff --git a/mingw-w64-crt/stdio/fgetpos.c b/mingw-w64-crt/stdio/fgetpos.c
> index 4fb0168f9bba..924c603c0295 100644
> --- a/mingw-w64-crt/stdio/fgetpos.c
> +++ b/mingw-w64-crt/stdio/fgetpos.c
> @@ -18,3 +18,6 @@ int __cdecl fgetpos(FILE *__restrict__ _File, fpos_t
> *__restrict__ _Pos)
> return ret;
> }
> int (__cdecl *__MINGW_IMP_SYMBOL(fgetpos))(FILE *__restrict__ _File, fpos_t
> *__restrict__ _Pos) = fgetpos;
> +
> +int __attribute__ ((alias ("fgetpos"))) __cdecl fgetpos64 (FILE
> *__restrict__ _File, fpos_t *__restrict__ _Pos);
> +extern int (__cdecl * __attribute__((alias
> (__MINGW64_STRINGIFY(__MINGW_IMP_SYMBOL(fgetpos)))))
> __MINGW_IMP_SYMBOL(fgetpos64))(FILE *__restrict__ _File, fpos_t *__restrict__
> _Pos);
> diff --git a/mingw-w64-crt/stdio/fgetpos64.c b/mingw-w64-crt/stdio/fgetpos64.c
> deleted file mode 100644
> index 2adb66efb7f7..000000000000
> --- a/mingw-w64-crt/stdio/fgetpos64.c
> +++ /dev/null
> @@ -1,5 +0,0 @@
> -#include <stdio.h>
> -
> -int __cdecl fgetpos64(FILE * __restrict__ _File ,fpos_t * __restrict__ _Pos){
> - return fgetpos(_File, _Pos);
> -}
> diff --git a/mingw-w64-crt/stdio/fsetpos.c b/mingw-w64-crt/stdio/fsetpos.c
> index 48237bcc0f37..1d3f0322d5b2 100644
> --- a/mingw-w64-crt/stdio/fsetpos.c
> +++ b/mingw-w64-crt/stdio/fsetpos.c
> @@ -24,3 +24,6 @@ int __cdecl fsetpos(FILE *__restrict__ _File, const fpos_t
> *__restrict__ _Pos)
> return fsetpos32(_File, &pos32);
> }
> int (__cdecl *__MINGW_IMP_SYMBOL(fsetpos))(FILE *__restrict__ _File, const
> fpos_t *__restrict__ _Pos) = fsetpos;
> +
> +int __attribute__ ((alias ("fsetpos"))) __cdecl fsetpos64 (FILE
> *__restrict__ _File, const fpos_t *__restrict__ _Pos);
> +extern int (__cdecl * __attribute__((alias
> (__MINGW64_STRINGIFY(__MINGW_IMP_SYMBOL(fsetpos)))))
> __MINGW_IMP_SYMBOL(fsetpos64))(FILE *__restrict__ _File, const fpos_t
> *__restrict__ _Pos);
> diff --git a/mingw-w64-crt/stdio/fsetpos64.c b/mingw-w64-crt/stdio/fsetpos64.c
> deleted file mode 100644
> index ab639f02fd4e..000000000000
> --- a/mingw-w64-crt/stdio/fsetpos64.c
> +++ /dev/null
> @@ -1,5 +0,0 @@
> -#include <stdio.h>
> -
> -int __cdecl fsetpos64(FILE *_File,const fpos_t *_Pos){ /* fsetpos already
> 64bit */
> - return fsetpos(_File,_Pos);
> -}
> --
> 2.20.1
>
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public