crt: Add emulation of _set_fmode() function for pre-msvcr80 import libs
Function _set_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 16800eb..a296bd8 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -565,6 +565,7 @@
misc/_get_fmode.c \
misc/_initterm_e.c \
misc/_set_doserrno.c \
+ misc/_set_fmode.c \
misc/_time64.c \
misc/imaxabs.c \
misc/lc_locale_func.c \
@@ -629,6 +630,7 @@
misc/_get_fmode.c \
misc/_initterm_e.c \
misc/_set_doserrno.c \
+ misc/_set_fmode.c \
misc/output_format.c \
misc/_get_errno.c \
misc/_set_errno.c \
@@ -902,6 +904,7 @@
misc/_recalloc.c \
misc/_set_doserrno.c \
misc/_set_errno.c \
+ misc/_set_fmode.c \
misc/imaxabs.c \
misc/invalid_parameter_handler.c \
misc/mbrtowc.c \
diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in b/mingw-w64-crt/lib-common/msvcrt.def.in
index 1970da2..2565bcc 100644
--- a/mingw-w64-crt/lib-common/msvcrt.def.in
+++ b/mingw-w64-crt/lib-common/msvcrt.def.in
@@ -1618,7 +1618,7 @@
F_ARM_ANY(_set_doserrno) ; i386 and x64 _set_doserrno replaced by emu
F_ARM_ANY(_set_errno) ; i386 and x64 _set_errno replaced by emu
_set_fileinfo
-_set_fmode
+F_ARM_ANY(_set_fmode) ; i386 and x64 _set_fmode replaced by emu
F_ARM_ANY(_set_output_format) ; i386 and x64 _set_output_format replaced by emu
_snprintf_c
_snprintf_c_l
diff --git a/mingw-w64-crt/misc/_set_fmode.c b/mingw-w64-crt/misc/_set_fmode.c
new file mode 100644
index 0000000..be784b9
--- /dev/null
+++ b/mingw-w64-crt/misc/_set_fmode.c
@@ -0,0 +1,13 @@
+/**
+ * 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>
+
+errno_t __cdecl _set_fmode(int value)
+{
+ _fmode = value;
+ return 0;
+}
+errno_t (__cdecl *__MINGW_IMP_SYMBOL(_set_fmode))(int) = _set_fmode;