crt: Move the msvcrt snprintf/vsnprintf aliases into separate object files

This avoids duplicate definitions, if something refers to e.g.
__ms_vsnprintf, while the inline vsnprintf also has been instantiated
in C++ mode. (In C++ mode, the inline vsnprintf function isn't marked
static.)

This should fix https://github.com/msys2/MINGW-packages/issues/6271.

Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 87bf701..9a1fe07 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -170,7 +170,9 @@
   misc/wcrtomb.c \
   stdio/acrt_iob_func.c \
   stdio/snprintf.c \
+  stdio/snprintf_alias.c \
   stdio/vsnprintf.c \
+  stdio/vsnprintf_alias.c \
   math/frexp.c
 
 src_msvcrt=\
diff --git a/mingw-w64-crt/stdio/snprintf.c b/mingw-w64-crt/stdio/snprintf.c
index ad9dd56..0bb5556 100644
--- a/mingw-w64-crt/stdio/snprintf.c
+++ b/mingw-w64-crt/stdio/snprintf.c
@@ -3,19 +3,8 @@
  * This file is part of the mingw-w64 runtime package.
  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  */
-
-#include <_mingw.h>
 #include <stdarg.h>
-#include <stddef.h>
-
-/* Intentionally not including stdio.h, as it unconditionally defines the
- * snprintf inline, and it can't be renamed with "#define snprintf othername"
- * either, as stdio.h contains "#undef snprintf". */
-
-_CRTIMP int __cdecl _vscprintf(const char * __restrict__ _Format,va_list _ArgList);
-_CRTIMP int __cdecl _vsnprintf(char * __restrict__ _Dest,size_t _Count,const char * __restrict__ _Format,va_list _Args);
-
-int __cdecl __ms_snprintf(char* buffer, size_t n, const char *format, ...);
+#include <stdio.h>
 
 int __cdecl __ms_snprintf(char* buffer, size_t n, const char *format, ...)
 {
@@ -47,5 +36,3 @@
   va_end(argptr);
   return retval;
 }
-
-int __attribute__ ((alias ("__ms_snprintf"))) __cdecl snprintf(char*, size_t, const char *, ...);
diff --git a/mingw-w64-crt/stdio/snprintf_alias.c b/mingw-w64-crt/stdio/snprintf_alias.c
new file mode 100644
index 0000000..1c34114
--- /dev/null
+++ b/mingw-w64-crt/stdio/snprintf_alias.c
@@ -0,0 +1,25 @@
+/**
+ * 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 <stdarg.h>
+#include <stddef.h>
+
+/* Intentionally not including stdio.h, as it unconditionally defines the
+ * snprintf inline, and it can't be renamed with "#define snprintf othername"
+ * either, as stdio.h contains "#undef snprintf". */
+
+int __cdecl __ms_vsnprintf(char *buffer, size_t n, const char *format, va_list arg);
+
+int __cdecl snprintf(char *buffer, size_t n, const char *format, ...)
+{
+  int retval;
+  va_list argptr;
+
+  va_start(argptr, format);
+  retval = __ms_vsnprintf(buffer, n, format, argptr);
+  va_end(argptr);
+  return retval;
+}
diff --git a/mingw-w64-crt/stdio/vsnprintf.c b/mingw-w64-crt/stdio/vsnprintf.c
index 9c4f83b..3641867 100644
--- a/mingw-w64-crt/stdio/vsnprintf.c
+++ b/mingw-w64-crt/stdio/vsnprintf.c
@@ -4,18 +4,8 @@
  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  */
 #define __CRT__NO_INLINE
-#include <_mingw.h>
 #include <stdarg.h>
-#include <stddef.h>
-
-/* Intentionally not including stdio.h, as it unconditionally defines the
- * vsnprintf inline, and it can't be renamed with "#define vsnprintf othername"
- * either, as stdio.h contains "#undef vsnprintf". */
-
-_CRTIMP int __cdecl _vscprintf(const char * __restrict__ _Format,va_list _ArgList);
-_CRTIMP int __cdecl _vsnprintf(char * __restrict__ _Dest,size_t _Count,const char * __restrict__ _Format,va_list _Args);
-
-int __cdecl __ms_vsnprintf (char *s,size_t n,const char *format,va_list arg);
+#include <stdio.h>
 
 int __cdecl __ms_vsnprintf (char *s,size_t n,const char *format,va_list arg)
 {
@@ -39,5 +29,3 @@
 
     return retval;
 }
-
-int __attribute__ ((alias ("__ms_vsnprintf"))) __cdecl vsnprintf(char*, size_t, const char *, va_list);
diff --git a/mingw-w64-crt/stdio/vsnprintf_alias.c b/mingw-w64-crt/stdio/vsnprintf_alias.c
new file mode 100644
index 0000000..8c7c9b9
--- /dev/null
+++ b/mingw-w64-crt/stdio/vsnprintf_alias.c
@@ -0,0 +1,19 @@
+/**
+ * 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 <stdarg.h>
+#include <stddef.h>
+
+/* Intentionally not including stdio.h, as it unconditionally defines the
+ * vsnprintf inline, and it can't be renamed with "#define vsnprintf othername"
+ * either, as stdio.h contains "#undef vsnprintf". */
+
+int __cdecl __ms_vsnprintf(char *buffer, size_t n, const char *format, va_list arg);
+
+int __cdecl vsnprintf(char *buffer, size_t n, const char *format, va_list arg)
+{
+  return __ms_vsnprintf(buffer, n, format, arg);
+}