crt: Add emulation of _get_fmode() function for pre-msvcr80 import libs Function _get_fmode() is available in msvcr80+, UCRT and also in msvcrt.dll since Windows Vista. Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index a489470..16800eb 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am
@@ -562,6 +562,7 @@ misc/_free_locale.c \ misc/_get_current_locale.c \ misc/_get_doserrno.c \ + misc/_get_fmode.c \ misc/_initterm_e.c \ misc/_set_doserrno.c \ misc/_time64.c \ @@ -625,6 +626,7 @@ misc/_free_locale.c \ misc/_get_current_locale.c \ misc/_get_doserrno.c \ + misc/_get_fmode.c \ misc/_initterm_e.c \ misc/_set_doserrno.c \ misc/output_format.c \ @@ -891,6 +893,7 @@ misc/_get_doserrno.c \ misc/_get_dstbias.c \ misc/_get_errno.c \ + misc/_get_fmode.c \ misc/_get_pgmptr.c \ misc/_get_timezone.c \ misc/_get_tzname.c \
diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in b/mingw-w64-crt/lib-common/msvcrt.def.in index ee7515c..1970da2 100644 --- a/mingw-w64-crt/lib-common/msvcrt.def.in +++ b/mingw-w64-crt/lib-common/msvcrt.def.in
@@ -1429,7 +1429,7 @@ _get_environ F_ARM_ANY(_get_errno) ; i386 and x64 _get_errno replaced by emu _get_fileinfo -_get_fmode +F_ARM_ANY(_get_fmode) ; i386 and x64 _get_fmode replaced by emu F_X86_ANY(_get_osplatform) F_X86_ANY(_get_osver) F_ARM_ANY(_get_output_format) ; i386 and x64 _get_output_format replaced by emu
diff --git a/mingw-w64-crt/misc/_get_fmode.c b/mingw-w64-crt/misc/_get_fmode.c new file mode 100644 index 0000000..0aab079 --- /dev/null +++ b/mingw-w64-crt/misc/_get_fmode.c
@@ -0,0 +1,20 @@ +/** + * 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 <stdlib.h> +#include <errno.h> + +errno_t __cdecl _get_fmode(int *value) +{ + if (!value) + { + errno = EINVAL; + return EINVAL; + } + + *value = _fmode; + return 0; +} +errno_t (__cdecl *__MINGW_IMP_SYMBOL(_get_fmode))(int *) = _get_fmode;