crt: Add a fallback _setmaxstdio for arm libmsvcrt-os.a

On arm, msvcrt.dll lacks the _setmaxstdio function; add a version
allows setting it up to the current value of _getmaxstdio().

Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index b104da3..0e38a0b 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -287,6 +287,7 @@
   misc/__p__fmode.c \
   misc/__p__wcmdln.c \
   misc/_getpid.c \
+  stdio/_setmaxstdio.c \
   stdio/gets.c
 
 if !ENABLE_SOFTMATH
@@ -381,6 +382,7 @@
   misc/__p__fmode.c \
   misc/__p__wcmdln.c \
   misc/_getpid.c \
+  stdio/_setmaxstdio.c \
   stdio/gets.c
 
 src_msvcr80_64=\
diff --git a/mingw-w64-crt/stdio/_setmaxstdio.c b/mingw-w64-crt/stdio/_setmaxstdio.c
new file mode 100644
index 0000000..9deb026
--- /dev/null
+++ b/mingw-w64-crt/stdio/_setmaxstdio.c
@@ -0,0 +1,14 @@
+/**
+ * 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>
+
+int __cdecl _setmaxstdio(int _Max) {
+  if (_Max < _IOB_ENTRIES || _Max > _getmaxstdio())
+    return -1;
+  return _Max;
+}
+int __cdecl (*__MINGW_IMP_SYMBOL(_setmaxstdio))(int) = _setmaxstdio;