This is first patch series which aims to de-duplicate declarations in CRT 
header files. This patch series covers functions declared in conio.h and 
sec_api/conio_s.h, and their wide equivalents. It adds two new header files: 
corecrt_wconio.h and sec_api/wconio_s.h.

(I really thought that the header file was called "correct_wconio.h" and not 
"corecrt_wconio.h" until I started writing this patch series)

When moving declarations to new header files, I removed one level of 
indentation from function declarations. Indentation was preserved in existing 
header files.

Patch 5 and the rest are mostly styling changes, feel free to drop some of them 
if you think that they are unnecessary.

One thing I am not sure about is whether we need to add _CRTIMP for _inp[w|d] 
and _outp[w|d] functions. They are also declared in intrin.h without _CRTIMP, 
so I wasn't sure about it. Let me know if it needs to be added, in which case 
I'll write a follow-up patch.

- Kirill Makurin
From cfa0ccc2d7dcd2f02f54f39e990bd8f4aafe8881 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 20 Dec 2025 08:57:20 +0900
Subject: [PATCH 01/10] headers: add missing __cdecl in declarations of _cgets
 and _cgetws

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/conio.h | 4 ++--
 mingw-w64-headers/crt/wchar.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mingw-w64-headers/crt/conio.h b/mingw-w64-headers/crt/conio.h
index 97b4e342d..c6df3c9b3 100644
--- a/mingw-w64-headers/crt/conio.h
+++ b/mingw-w64-headers/crt/conio.h
@@ -14,7 +14,7 @@
 extern "C" {
 #endif
 
-  _CRTIMP char *_cgets(char *_Buffer) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP char *__cdecl _cgets(char *_Buffer) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP int __cdecl _cputs(const char *_Str);
   _CRTIMP int __cdecl _getch(void);
   _CRTIMP int __cdecl _getche(void);
@@ -138,7 +138,7 @@ extern "C" {
 #define WEOF (wint_t)(0xFFFF)
 #endif
 
-  _CRTIMP wchar_t *_cgetws(wchar_t *_Buffer) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP wchar_t *__cdecl _cgetws(wchar_t *_Buffer) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP wint_t __cdecl _getwch(void);
   _CRTIMP wint_t __cdecl _getwche(void);
   _CRTIMP wint_t __cdecl _putwch(wchar_t _WCh);
diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h
index 6c489e8ff..2782d14c2 100644
--- a/mingw-w64-headers/crt/wchar.h
+++ b/mingw-w64-headers/crt/wchar.h
@@ -278,7 +278,7 @@ _CRTIMP FILE *__cdecl __acrt_iob_func(unsigned index);
 #define WEOF (wint_t)(0xFFFF)
 #endif
 
-  _CRTIMP wchar_t *_cgetws(wchar_t *_Buffer) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP wchar_t *__cdecl _cgetws(wchar_t *_Buffer) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP wint_t __cdecl _getwch(void);
   _CRTIMP wint_t __cdecl _getwche(void);
   _CRTIMP wint_t __cdecl _putwch(wchar_t _WCh);
-- 
2.51.0.windows.1

From 9719d8facbc3d68c2e93ba918bd03ea619a34ce3 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 20 Dec 2025 09:00:08 +0900
Subject: [PATCH 02/10] headers: de-duplicate declarations in conio.h and
 wchar.h

Move duplicating declarations to corecrt_wconio.h and
include it from both conio.h and wchar.h.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/conio.h          | 112 +--------------------
 mingw-w64-headers/crt/corecrt_wconio.h | 131 +++++++++++++++++++++++++
 mingw-w64-headers/crt/wchar.h          | 113 +--------------------
 3 files changed, 133 insertions(+), 223 deletions(-)
 create mode 100644 mingw-w64-headers/crt/corecrt_wconio.h

diff --git a/mingw-w64-headers/crt/conio.h b/mingw-w64-headers/crt/conio.h
index c6df3c9b3..44b6889ff 100644
--- a/mingw-w64-headers/crt/conio.h
+++ b/mingw-w64-headers/crt/conio.h
@@ -8,6 +8,7 @@
 
 #include <crtdefs.h>
 #include <corecrt_stdio_config.h>
+#include <corecrt_wconio.h>
 #include <stddef.h>
 
 #ifdef __cplusplus
@@ -131,117 +132,6 @@ extern "C" {
   _CRTIMP int __cdecl _ungetch_nolock(int _Ch);
 #endif
 
-#ifndef _WCONIO_DEFINED
-#define _WCONIO_DEFINED
-
-#ifndef WEOF
-#define WEOF (wint_t)(0xFFFF)
-#endif
-
-  _CRTIMP wchar_t *__cdecl _cgetws(wchar_t *_Buffer) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  _CRTIMP wint_t __cdecl _getwch(void);
-  _CRTIMP wint_t __cdecl _getwche(void);
-  _CRTIMP wint_t __cdecl _putwch(wchar_t _WCh);
-  _CRTIMP wint_t __cdecl _ungetwch(wint_t _WCh);
-  _CRTIMP int __cdecl _cputws(const wchar_t *_String);
-#ifdef _UCRT
-  int __cdecl __conio_common_vcwprintf(unsigned __int64 _Options, const 
wchar_t *_Format, _locale_t _Locale, va_list _ArgList);
-  int __cdecl __conio_common_vcwprintf_p(unsigned __int64 _Options, const 
wchar_t *_Format, _locale_t _Locale, va_list _ArgList);
-  int __cdecl __conio_common_vcwprintf_s(unsigned __int64 _Options, const 
wchar_t *_Format, _locale_t _Locale, va_list _ArgList);
-  int __cdecl __conio_common_vcwscanf(unsigned __int64 _Options, const wchar_t 
*_Format, _locale_t _Locale, va_list _ArgList);
-
-  __mingw_ovr int __cdecl _vcwprintf(const wchar_t * __restrict__ 
_Format,va_list _ArgList)
-  {
-    return __conio_common_vcwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, 
_Format, NULL, _ArgList);
-  }
-  __mingw_ovr int __cdecl _cwprintf(const wchar_t * __restrict__ _Format,...)
-  {
-    __builtin_va_list _ArgList;
-    int _Ret;
-    __builtin_va_start(_ArgList, _Format);
-    _Ret = _vcwprintf(_Format, _ArgList);
-    __builtin_va_end(_ArgList);
-    return _Ret;
-  }
-  __mingw_ovr __MINGW_ATTRIB_DEPRECATED_SEC_WARN
-  int __cdecl _cwscanf(const wchar_t * __restrict__ _Format,...)
-  {
-    __builtin_va_list _ArgList;
-    int _Ret;
-    __builtin_va_start(_ArgList, _Format);
-    _Ret = __conio_common_vcwscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, _Format, 
NULL, _ArgList);
-    __builtin_va_end(_ArgList);
-    return _Ret;
-  }
-  __mingw_ovr __MINGW_ATTRIB_DEPRECATED_SEC_WARN
-  int __cdecl _cwscanf_l(const wchar_t * __restrict__ _Format,_locale_t 
_Locale,...)
-  {
-    __builtin_va_list _ArgList;
-    int _Ret;
-    __builtin_va_start(_ArgList, _Locale);
-    _Ret = __conio_common_vcwscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, _Format, 
_Locale, _ArgList);
-    __builtin_va_end(_ArgList);
-    return _Ret;
-  }
-  __mingw_ovr int __cdecl _vcwprintf_p(const wchar_t * __restrict__ 
_Format,va_list _ArgList)
-  {
-    return __conio_common_vcwprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, 
_Format, NULL, _ArgList);
-  }
-  __mingw_ovr int __cdecl _cwprintf_p(const wchar_t * __restrict__ _Format,...)
-  {
-    __builtin_va_list _ArgList;
-    int _Ret;
-    __builtin_va_start(_ArgList, _Format);
-    _Ret = _vcwprintf_p(_Format, _ArgList);
-    __builtin_va_end(_ArgList);
-    return _Ret;
-  }
-  __mingw_ovr int __cdecl _vcwprintf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList)
-  {
-    return __conio_common_vcwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, 
_Format, _Locale, _ArgList);
-  }
-  __mingw_ovr int __cdecl _cwprintf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,...)
-  {
-    __builtin_va_list _ArgList;
-    int _Ret;
-    __builtin_va_start(_ArgList, _Locale);
-    _Ret = _vcwprintf_l(_Format, _Locale, _ArgList);
-    __builtin_va_end(_ArgList);
-    return _Ret;
-  }
-  __mingw_ovr int __cdecl _vcwprintf_p_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList)
-  {
-    return __conio_common_vcwprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, 
_Format, _Locale, _ArgList);
-  }
-  __mingw_ovr int __cdecl _cwprintf_p_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,...)
-  {
-    __builtin_va_list _ArgList;
-    int _Ret;
-    __builtin_va_start(_ArgList, _Locale);
-    _Ret = _vcwprintf_p_l(_Format, _Locale, _ArgList);
-    __builtin_va_end(_ArgList);
-    return _Ret;
-  }
-#else
-  _CRTIMP int __cdecl _cwprintf(const wchar_t * __restrict__ _Format,...);
-  _CRTIMP int __cdecl _cwscanf(const wchar_t * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  _CRTIMP int __cdecl _cwscanf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  _CRTIMP int __cdecl _vcwprintf(const wchar_t * __restrict__ _Format,va_list 
_ArgList);
-  _CRTIMP int __cdecl _cwprintf_p(const wchar_t * __restrict__ _Format,...);
-  _CRTIMP int __cdecl _vcwprintf_p(const wchar_t * __restrict__ 
_Format,va_list _ArgList);
-  _CRTIMP int __cdecl _cwprintf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,...);
-  _CRTIMP int __cdecl _vcwprintf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList);
-  _CRTIMP int __cdecl _cwprintf_p_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,...);
-  _CRTIMP int __cdecl _vcwprintf_p_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList);
-#endif
-#if __MSVCRT_VERSION__ >= 0x800
-  _CRTIMP wint_t __cdecl _putwch_nolock(wchar_t _WCh);
-  _CRTIMP wint_t __cdecl _getwch_nolock(void);
-  _CRTIMP wint_t __cdecl _getwche_nolock(void);
-  _CRTIMP wint_t __cdecl _ungetwch_nolock(wint_t _WCh);
-#endif
-#endif
-
 #ifndef        NO_OLDNAMES
   char *__cdecl cgets(char *_Buffer) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
 
diff --git a/mingw-w64-headers/crt/corecrt_wconio.h 
b/mingw-w64-headers/crt/corecrt_wconio.h
new file mode 100644
index 000000000..0320e93a6
--- /dev/null
+++ b/mingw-w64-headers/crt/corecrt_wconio.h
@@ -0,0 +1,131 @@
+/**
+ * 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.
+ */
+
+#ifndef _INC_CORECRT_WCONIO
+#define _INC_CORECRT_WCONIO
+
+#include <corecrt.h>
+#include <corecrt_stdio_config.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef WEOF
+#define WEOF (wint_t)(0xFFFF)
+#endif
+
+_CRTIMP wchar_t *__cdecl _cgetws(wchar_t *_Buffer) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+_CRTIMP wint_t __cdecl _getwch(void);
+_CRTIMP wint_t __cdecl _getwche(void);
+_CRTIMP wint_t __cdecl _putwch(wchar_t _WCh);
+_CRTIMP wint_t __cdecl _ungetwch(wint_t _WCh);
+_CRTIMP int __cdecl _cputws(const wchar_t *_String);
+
+#ifdef _UCRT
+int __cdecl __conio_common_vcwprintf(unsigned __int64 _Options, const wchar_t 
*_Format, _locale_t _Locale, va_list _ArgList);
+int __cdecl __conio_common_vcwprintf_p(unsigned __int64 _Options, const 
wchar_t *_Format, _locale_t _Locale, va_list _ArgList);
+int __cdecl __conio_common_vcwprintf_s(unsigned __int64 _Options, const 
wchar_t *_Format, _locale_t _Locale, va_list _ArgList);
+int __cdecl __conio_common_vcwscanf(unsigned __int64 _Options, const wchar_t 
*_Format, _locale_t _Locale, va_list _ArgList);
+
+__mingw_ovr int __cdecl _vcwprintf(const wchar_t * __restrict__ 
_Format,va_list _ArgList)
+{
+  return __conio_common_vcwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Format, 
NULL, _ArgList);
+}
+__mingw_ovr int __cdecl _cwprintf(const wchar_t * __restrict__ _Format,...)
+{
+  __builtin_va_list _ArgList;
+  int _Ret;
+  __builtin_va_start(_ArgList, _Format);
+  _Ret = _vcwprintf(_Format, _ArgList);
+  __builtin_va_end(_ArgList);
+  return _Ret;
+}
+__mingw_ovr __MINGW_ATTRIB_DEPRECATED_SEC_WARN
+int __cdecl _cwscanf(const wchar_t * __restrict__ _Format,...)
+{
+  __builtin_va_list _ArgList;
+  int _Ret;
+  __builtin_va_start(_ArgList, _Format);
+  _Ret = __conio_common_vcwscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, _Format, 
NULL, _ArgList);
+  __builtin_va_end(_ArgList);
+  return _Ret;
+}
+__mingw_ovr __MINGW_ATTRIB_DEPRECATED_SEC_WARN
+int __cdecl _cwscanf_l(const wchar_t * __restrict__ _Format,_locale_t 
_Locale,...)
+{
+  __builtin_va_list _ArgList;
+  int _Ret;
+  __builtin_va_start(_ArgList, _Locale);
+  _Ret = __conio_common_vcwscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, _Format, 
_Locale, _ArgList);
+  __builtin_va_end(_ArgList);
+  return _Ret;
+}
+__mingw_ovr int __cdecl _vcwprintf_p(const wchar_t * __restrict__ 
_Format,va_list _ArgList)
+{
+  return __conio_common_vcwprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, 
_Format, NULL, _ArgList);
+}
+__mingw_ovr int __cdecl _cwprintf_p(const wchar_t * __restrict__ _Format,...)
+{
+  __builtin_va_list _ArgList;
+  int _Ret;
+  __builtin_va_start(_ArgList, _Format);
+  _Ret = _vcwprintf_p(_Format, _ArgList);
+  __builtin_va_end(_ArgList);
+  return _Ret;
+}
+__mingw_ovr int __cdecl _vcwprintf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList)
+{
+  return __conio_common_vcwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Format, 
_Locale, _ArgList);
+}
+__mingw_ovr int __cdecl _cwprintf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,...)
+{
+  __builtin_va_list _ArgList;
+  int _Ret;
+  __builtin_va_start(_ArgList, _Locale);
+  _Ret = _vcwprintf_l(_Format, _Locale, _ArgList);
+  __builtin_va_end(_ArgList);
+  return _Ret;
+}
+__mingw_ovr int __cdecl _vcwprintf_p_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList)
+{
+  return __conio_common_vcwprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, 
_Format, _Locale, _ArgList);
+}
+__mingw_ovr int __cdecl _cwprintf_p_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,...)
+{
+  __builtin_va_list _ArgList;
+  int _Ret;
+  __builtin_va_start(_ArgList, _Locale);
+  _Ret = _vcwprintf_p_l(_Format, _Locale, _ArgList);
+  __builtin_va_end(_ArgList);
+  return _Ret;
+}
+#else /* !_UCRT */
+_CRTIMP int __cdecl _cwprintf(const wchar_t * __restrict__ _Format,...);
+_CRTIMP int __cdecl _cwscanf(const wchar_t * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+_CRTIMP int __cdecl _cwscanf_l(const wchar_t * __restrict__ _Format,_locale_t 
_Locale,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+_CRTIMP int __cdecl _vcwprintf(const wchar_t * __restrict__ _Format,va_list 
_ArgList);
+_CRTIMP int __cdecl _cwprintf_p(const wchar_t * __restrict__ _Format,...);
+_CRTIMP int __cdecl _vcwprintf_p(const wchar_t * __restrict__ _Format,va_list 
_ArgList);
+_CRTIMP int __cdecl _cwprintf_l(const wchar_t * __restrict__ _Format,_locale_t 
_Locale,...);
+_CRTIMP int __cdecl _vcwprintf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList);
+_CRTIMP int __cdecl _cwprintf_p_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,...);
+_CRTIMP int __cdecl _vcwprintf_p_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList);
+#endif /* _UCRT */
+
+#if __MSVCRT_VERSION__ >= 0x800
+_CRTIMP wint_t __cdecl _putwch_nolock(wchar_t _WCh);
+_CRTIMP wint_t __cdecl _getwch_nolock(void);
+_CRTIMP wint_t __cdecl _getwche_nolock(void);
+_CRTIMP wint_t __cdecl _ungetwch_nolock(wint_t _WCh);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _INC_CORECRT_WCONIO */
diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h
index 2782d14c2..3fd9413c9 100644
--- a/mingw-w64-headers/crt/wchar.h
+++ b/mingw-w64-headers/crt/wchar.h
@@ -8,6 +8,7 @@
 
 #include <corecrt.h>
 #include <corecrt_stdio_config.h>
+#include <corecrt_wconio.h>
 #include <corecrt_wstdlib.h>
 #include <corecrt_wctype.h>
 
@@ -271,118 +272,6 @@ _CRTIMP FILE *__cdecl __acrt_iob_func(unsigned index);
 #endif
 #endif
 
-#ifndef _WCONIO_DEFINED
-#define _WCONIO_DEFINED
-
-#ifndef WEOF
-#define WEOF (wint_t)(0xFFFF)
-#endif
-
-  _CRTIMP wchar_t *__cdecl _cgetws(wchar_t *_Buffer) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  _CRTIMP wint_t __cdecl _getwch(void);
-  _CRTIMP wint_t __cdecl _getwche(void);
-  _CRTIMP wint_t __cdecl _putwch(wchar_t _WCh);
-  _CRTIMP wint_t __cdecl _ungetwch(wint_t _WCh);
-  _CRTIMP int __cdecl _cputws(const wchar_t *_String);
-#ifdef _UCRT
-  int __cdecl __conio_common_vcwprintf(unsigned __int64 _Options, const 
wchar_t *_Format, _locale_t _Locale, va_list _ArgList);
-  int __cdecl __conio_common_vcwprintf_p(unsigned __int64 _Options, const 
wchar_t *_Format, _locale_t _Locale, va_list _ArgList);
-  int __cdecl __conio_common_vcwprintf_s(unsigned __int64 _Options, const 
wchar_t *_Format, _locale_t _Locale, va_list _ArgList);
-  int __cdecl __conio_common_vcwscanf(unsigned __int64 _Options, const wchar_t 
*_Format, _locale_t _Locale, va_list _ArgList);
-
-  __mingw_ovr int __cdecl _vcwprintf(const wchar_t * __restrict__ 
_Format,va_list _ArgList)
-  {
-    return __conio_common_vcwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, 
_Format, NULL, _ArgList);
-  }
-  __mingw_ovr int __cdecl _cwprintf(const wchar_t * __restrict__ _Format,...)
-  {
-    __builtin_va_list _ArgList;
-    int _Ret;
-    __builtin_va_start(_ArgList, _Format);
-    _Ret = _vcwprintf(_Format, _ArgList);
-    __builtin_va_end(_ArgList);
-    return _Ret;
-  }
-  __mingw_ovr __MINGW_ATTRIB_DEPRECATED_SEC_WARN
-  int __cdecl _cwscanf(const wchar_t * __restrict__ _Format,...)
-  {
-    __builtin_va_list _ArgList;
-    int _Ret;
-    __builtin_va_start(_ArgList, _Format);
-    _Ret = __conio_common_vcwscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, _Format, 
NULL, _ArgList);
-    __builtin_va_end(_ArgList);
-    return _Ret;
-  }
-  __mingw_ovr __MINGW_ATTRIB_DEPRECATED_SEC_WARN
-  int __cdecl _cwscanf_l(const wchar_t * __restrict__ _Format,_locale_t 
_Locale,...)
-  {
-    __builtin_va_list _ArgList;
-    int _Ret;
-    __builtin_va_start(_ArgList, _Locale);
-    _Ret = __conio_common_vcwscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, _Format, 
_Locale, _ArgList);
-    __builtin_va_end(_ArgList);
-    return _Ret;
-  }
-  __mingw_ovr int __cdecl _vcwprintf_p(const wchar_t * __restrict__ 
_Format,va_list _ArgList)
-  {
-    return __conio_common_vcwprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, 
_Format, NULL, _ArgList);
-  }
-  __mingw_ovr int __cdecl _cwprintf_p(const wchar_t * __restrict__ _Format,...)
-  {
-    __builtin_va_list _ArgList;
-    int _Ret;
-    __builtin_va_start(_ArgList, _Format);
-    _Ret = _vcwprintf_p(_Format, _ArgList);
-    __builtin_va_end(_ArgList);
-    return _Ret;
-  }
-  __mingw_ovr int __cdecl _vcwprintf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList)
-  {
-    return __conio_common_vcwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, 
_Format, _Locale, _ArgList);
-  }
-  __mingw_ovr int __cdecl _cwprintf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,...)
-  {
-    __builtin_va_list _ArgList;
-    int _Ret;
-    __builtin_va_start(_ArgList, _Locale);
-    _Ret = _vcwprintf_l(_Format, _Locale, _ArgList);
-    __builtin_va_end(_ArgList);
-    return _Ret;
-  }
-  __mingw_ovr int __cdecl _vcwprintf_p_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList)
-  {
-    return __conio_common_vcwprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, 
_Format, _Locale, _ArgList);
-  }
-  __mingw_ovr int __cdecl _cwprintf_p_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,...)
-  {
-    __builtin_va_list _ArgList;
-    int _Ret;
-    __builtin_va_start(_ArgList, _Locale);
-    _Ret = _vcwprintf_p_l(_Format, _Locale, _ArgList);
-    __builtin_va_end(_ArgList);
-    return _Ret;
-  }
-#else
-  _CRTIMP int __cdecl _cwprintf(const wchar_t * __restrict__ _Format,...);
-  _CRTIMP int __cdecl _cwscanf(const wchar_t * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  _CRTIMP int __cdecl _cwscanf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  _CRTIMP int __cdecl _vcwprintf(const wchar_t * __restrict__ _Format,va_list 
_ArgList);
-  _CRTIMP int __cdecl _cwprintf_p(const wchar_t * __restrict__ _Format,...);
-  _CRTIMP int __cdecl _vcwprintf_p(const wchar_t * __restrict__ 
_Format,va_list _ArgList);
-
-  _CRTIMP int __cdecl _cwprintf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,...);
-  _CRTIMP int __cdecl _vcwprintf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList);
-  _CRTIMP int __cdecl _cwprintf_p_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,...);
-  _CRTIMP int __cdecl _vcwprintf_p_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList);
-#endif
-#if __MSVCRT_VERSION__ >= 0x800
-  wint_t __cdecl _putwch_nolock(wchar_t _WCh);
-  wint_t __cdecl _getwch_nolock(void);
-  wint_t __cdecl _getwche_nolock(void);
-  wint_t __cdecl _ungetwch_nolock(wint_t _WCh);
-#endif
-#endif
-
 #ifdef _UCRT
   int __cdecl __stdio_common_vswprintf_p(unsigned __int64 _Options, wchar_t 
*_Str, size_t _Len, const wchar_t *_Format, _locale_t _Locale, va_list 
_ArgList);
   int __cdecl __stdio_common_vfwprintf_p(unsigned __int64 _Options, FILE 
*_File, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList);
-- 
2.51.0.windows.1

From e49f389b543d9ebb0b185abdf66614e8b531379e Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 20 Dec 2025 09:00:51 +0900
Subject: [PATCH 03/10] headers: sec_api/wchar_s.h: add missing secure template
 override for _cgetws_s

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/sec_api/wchar_s.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mingw-w64-headers/crt/sec_api/wchar_s.h 
b/mingw-w64-headers/crt/sec_api/wchar_s.h
index de932a8bb..c072e3bb1 100644
--- a/mingw-w64-headers/crt/sec_api/wchar_s.h
+++ b/mingw-w64-headers/crt/sec_api/wchar_s.h
@@ -30,6 +30,7 @@ extern "C" {
 #ifndef _WCONIO_S_DEFINED
 #define _WCONIO_S_DEFINED
   _SECIMP errno_t __cdecl _cgetws_s (wchar_t *_Buffer,size_t 
_SizeInWords,size_t *_SizeRead);
+  __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1(errno_t, _cgetws_s, wchar_t, _Buffer, 
size_t*, _SizeRead)
   _SECIMP int __cdecl _cwprintf_s (const wchar_t *_Format,...);
   _CRTIMP int __cdecl _cwscanf_s(const wchar_t *_Format,...);
   _CRTIMP int __cdecl _cwscanf_s_l(const wchar_t *_Format,_locale_t 
_Locale,...);
-- 
2.51.0.windows.1

From 0ca8a91f4119552940ac63bbc4fec1f09de8c3e7 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 20 Dec 2025 09:03:37 +0900
Subject: [PATCH 04/10] headers: de-duplicate declarations in ses_api/conio_s.h
 and sec_aip/wchar_s.h

Move duplicating declarations declartions to sec_api/wconio_s.h
and include it from corecrt_wconio.h.

There is no need to inlcude sec_api/wconio_s.h from conio.h,
sec_api/conio_s.h, wchar.h or sec_api/wchar.h since they all
include corecrt_wconio.h directly or indirectly.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/corecrt_wconio.h   |  2 ++
 mingw-w64-headers/crt/sec_api/conio_s.h  | 13 --------
 mingw-w64-headers/crt/sec_api/wchar_s.h  | 12 --------
 mingw-w64-headers/crt/sec_api/wconio_s.h | 39 ++++++++++++++++++++++++
 4 files changed, 41 insertions(+), 25 deletions(-)
 create mode 100644 mingw-w64-headers/crt/sec_api/wconio_s.h

diff --git a/mingw-w64-headers/crt/corecrt_wconio.h 
b/mingw-w64-headers/crt/corecrt_wconio.h
index 0320e93a6..ed93748ac 100644
--- a/mingw-w64-headers/crt/corecrt_wconio.h
+++ b/mingw-w64-headers/crt/corecrt_wconio.h
@@ -128,4 +128,6 @@ _CRTIMP wint_t __cdecl _ungetwch_nolock(wint_t _WCh);
 }
 #endif
 
+#include <sec_api/wconio_s.h>
+
 #endif /* _INC_CORECRT_WCONIO */
diff --git a/mingw-w64-headers/crt/sec_api/conio_s.h 
b/mingw-w64-headers/crt/sec_api/conio_s.h
index d7f0e9eb3..4eb03d200 100644
--- a/mingw-w64-headers/crt/sec_api/conio_s.h
+++ b/mingw-w64-headers/crt/sec_api/conio_s.h
@@ -32,19 +32,6 @@ extern "C" {
   _SECIMP int __cdecl _cprintf_s_l (const char *_Format,_locale_t _Locale,...);
   _SECIMP int __cdecl _vcprintf_s_l (const char *_Format,_locale_t 
_Locale,va_list _ArgList);
 
-#ifndef _WCONIO_S_DEFINED
-#define _WCONIO_S_DEFINED
-  _SECIMP errno_t __cdecl _cgetws_s (wchar_t *_Buffer,size_t 
_SizeInWords,size_t *_SizeRead);
-  __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1(errno_t, _cgetws_s, wchar_t, _Buffer, 
size_t*, _SizeRead)
-
-  _SECIMP int __cdecl _cwprintf_s (const wchar_t *_Format,...);
-  _CRTIMP int __cdecl _cwscanf_s(const wchar_t *_Format,...);
-  _CRTIMP int __cdecl _cwscanf_s_l(const wchar_t *_Format,_locale_t 
_Locale,...);
-  _SECIMP int __cdecl _vcwprintf_s (const wchar_t *_Format,va_list _ArgList);
-  _SECIMP int __cdecl _cwprintf_s_l (const wchar_t *_Format,_locale_t 
_Locale,...);
-  _SECIMP int __cdecl _vcwprintf_s_l (const wchar_t *_Format,_locale_t 
_Locale,va_list _ArgList);
-#endif
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/mingw-w64-headers/crt/sec_api/wchar_s.h 
b/mingw-w64-headers/crt/sec_api/wchar_s.h
index c072e3bb1..a5fe23f4b 100644
--- a/mingw-w64-headers/crt/sec_api/wchar_s.h
+++ b/mingw-w64-headers/crt/sec_api/wchar_s.h
@@ -27,18 +27,6 @@ extern "C" {
   _SECIMP errno_t __cdecl _wmktemp_s (wchar_t *_TemplateName,size_t 
_SizeInWords);
 #endif
 
-#ifndef _WCONIO_S_DEFINED
-#define _WCONIO_S_DEFINED
-  _SECIMP errno_t __cdecl _cgetws_s (wchar_t *_Buffer,size_t 
_SizeInWords,size_t *_SizeRead);
-  __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1(errno_t, _cgetws_s, wchar_t, _Buffer, 
size_t*, _SizeRead)
-  _SECIMP int __cdecl _cwprintf_s (const wchar_t *_Format,...);
-  _CRTIMP int __cdecl _cwscanf_s(const wchar_t *_Format,...);
-  _CRTIMP int __cdecl _cwscanf_s_l(const wchar_t *_Format,_locale_t 
_Locale,...);
-  _SECIMP int __cdecl _vcwprintf_s (const wchar_t *_Format,va_list _ArgList);
-  _SECIMP int __cdecl _cwprintf_s_l (const wchar_t *_Format,_locale_t 
_Locale,...);
-  _SECIMP int __cdecl _vcwprintf_s_l (const wchar_t *_Format,_locale_t 
_Locale,va_list _ArgList);
-#endif
-
 #ifndef _WSTDIO_S_DEFINED
 #define _WSTDIO_S_DEFINED
   _CRTIMP wchar_t *__cdecl _getws_s(wchar_t *_Str,size_t _SizeInWords);
diff --git a/mingw-w64-headers/crt/sec_api/wconio_s.h 
b/mingw-w64-headers/crt/sec_api/wconio_s.h
new file mode 100644
index 000000000..336edc5a7
--- /dev/null
+++ b/mingw-w64-headers/crt/sec_api/wconio_s.h
@@ -0,0 +1,39 @@
+/**
+ * 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.
+ */
+
+#ifndef _INC_WCONIO_S
+#define _INC_WCONIO_S
+
+#include <corecrt_wconio.h>
+
+#if defined(__LIBMSVCRT__)
+/* When building mingw-w64, this should be blank.  */
+#define _SECIMP
+#else
+#ifndef _SECIMP
+#define _SECIMP __declspec(dllimport)
+#endif /* _SECIMP */
+#endif /* defined(__LIBMSVCRT__) */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_SECIMP errno_t __cdecl _cgetws_s (wchar_t *_Buffer,size_t _SizeInWords,size_t 
*_SizeRead);
+__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1(errno_t, _cgetws_s, wchar_t, _Buffer, 
size_t*, _SizeRead)
+
+_SECIMP int __cdecl _cwprintf_s (const wchar_t *_Format,...);
+_CRTIMP int __cdecl _cwscanf_s(const wchar_t *_Format,...);
+_CRTIMP int __cdecl _cwscanf_s_l(const wchar_t *_Format,_locale_t _Locale,...);
+_SECIMP int __cdecl _vcwprintf_s (const wchar_t *_Format,va_list _ArgList);
+_SECIMP int __cdecl _cwprintf_s_l (const wchar_t *_Format,_locale_t 
_Locale,...);
+_SECIMP int __cdecl _vcwprintf_s_l (const wchar_t *_Format,_locale_t 
_Locale,va_list _ArgList);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _INC_WCONIO_S */
-- 
2.51.0.windows.1

From 4306aabaf19f201e8ae9ba7ade7f8f54455d997f Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 20 Dec 2025 09:29:55 +0900
Subject: [PATCH 05/10] headers: corecrt_wconio.h: reorder declarations

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/corecrt_wconio.h | 41 +++++++++++++++++---------
 1 file changed, 27 insertions(+), 14 deletions(-)

diff --git a/mingw-w64-headers/crt/corecrt_wconio.h 
b/mingw-w64-headers/crt/corecrt_wconio.h
index ed93748ac..7b741a2b7 100644
--- a/mingw-w64-headers/crt/corecrt_wconio.h
+++ b/mingw-w64-headers/crt/corecrt_wconio.h
@@ -19,12 +19,32 @@ extern "C" {
 #define WEOF (wint_t)(0xFFFF)
 #endif
 
+/**
+ * Functions to read/write strings from/to console.
+ */
+
 _CRTIMP wchar_t *__cdecl _cgetws(wchar_t *_Buffer) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+_CRTIMP int __cdecl _cputws(const wchar_t *_String);
+
+/**
+ * Functions to read/write single characters from/to console.
+ */
+
 _CRTIMP wint_t __cdecl _getwch(void);
 _CRTIMP wint_t __cdecl _getwche(void);
 _CRTIMP wint_t __cdecl _putwch(wchar_t _WCh);
 _CRTIMP wint_t __cdecl _ungetwch(wint_t _WCh);
-_CRTIMP int __cdecl _cputws(const wchar_t *_String);
+
+#if __MSVCRT_VERSION__ >= 0x800
+_CRTIMP wint_t __cdecl _getwch_nolock(void);
+_CRTIMP wint_t __cdecl _getwche_nolock(void);
+_CRTIMP wint_t __cdecl _putwch_nolock(wchar_t _WCh);
+_CRTIMP wint_t __cdecl _ungetwch_nolock(wint_t _WCh);
+#endif
+
+/**
+ * Formatted console I/O functions.
+ */
 
 #ifdef _UCRT
 int __cdecl __conio_common_vcwprintf(unsigned __int64 _Options, const wchar_t 
*_Format, _locale_t _Locale, va_list _ArgList);
@@ -106,24 +126,17 @@ __mingw_ovr int __cdecl _cwprintf_p_l(const wchar_t * 
__restrict__ _Format,_loca
 }
 #else /* !_UCRT */
 _CRTIMP int __cdecl _cwprintf(const wchar_t * __restrict__ _Format,...);
-_CRTIMP int __cdecl _cwscanf(const wchar_t * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-_CRTIMP int __cdecl _cwscanf_l(const wchar_t * __restrict__ _Format,_locale_t 
_Locale,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-_CRTIMP int __cdecl _vcwprintf(const wchar_t * __restrict__ _Format,va_list 
_ArgList);
-_CRTIMP int __cdecl _cwprintf_p(const wchar_t * __restrict__ _Format,...);
-_CRTIMP int __cdecl _vcwprintf_p(const wchar_t * __restrict__ _Format,va_list 
_ArgList);
 _CRTIMP int __cdecl _cwprintf_l(const wchar_t * __restrict__ _Format,_locale_t 
_Locale,...);
-_CRTIMP int __cdecl _vcwprintf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList);
+_CRTIMP int __cdecl _cwprintf_p(const wchar_t * __restrict__ _Format,...);
 _CRTIMP int __cdecl _cwprintf_p_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,...);
+_CRTIMP int __cdecl _vcwprintf(const wchar_t * __restrict__ _Format,va_list 
_ArgList);
+_CRTIMP int __cdecl _vcwprintf_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList);
+_CRTIMP int __cdecl _vcwprintf_p(const wchar_t * __restrict__ _Format,va_list 
_ArgList);
 _CRTIMP int __cdecl _vcwprintf_p_l(const wchar_t * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList);
+_CRTIMP int __cdecl _cwscanf(const wchar_t * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+_CRTIMP int __cdecl _cwscanf_l(const wchar_t * __restrict__ _Format,_locale_t 
_Locale,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 #endif /* _UCRT */
 
-#if __MSVCRT_VERSION__ >= 0x800
-_CRTIMP wint_t __cdecl _putwch_nolock(wchar_t _WCh);
-_CRTIMP wint_t __cdecl _getwch_nolock(void);
-_CRTIMP wint_t __cdecl _getwche_nolock(void);
-_CRTIMP wint_t __cdecl _ungetwch_nolock(wint_t _WCh);
-#endif
-
 #ifdef __cplusplus
 }
 #endif
-- 
2.51.0.windows.1

From 72c2e13f494ed5d6e94cf58192733ef6f99662aa Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 20 Dec 2025 09:31:09 +0900
Subject: [PATCH 06/10] headers: sec_api/wconio_s.h: reorder declarations

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/sec_api/wconio_s.h | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/mingw-w64-headers/crt/sec_api/wconio_s.h 
b/mingw-w64-headers/crt/sec_api/wconio_s.h
index 336edc5a7..4e1390760 100644
--- a/mingw-w64-headers/crt/sec_api/wconio_s.h
+++ b/mingw-w64-headers/crt/sec_api/wconio_s.h
@@ -22,15 +22,23 @@
 extern "C" {
 #endif
 
+/**
+ * Functions to read/write strings from/to console.
+ */
+
 _SECIMP errno_t __cdecl _cgetws_s (wchar_t *_Buffer,size_t _SizeInWords,size_t 
*_SizeRead);
 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1(errno_t, _cgetws_s, wchar_t, _Buffer, 
size_t*, _SizeRead)
 
+/**
+ * Formatted console I/O functions.
+ */
+
 _SECIMP int __cdecl _cwprintf_s (const wchar_t *_Format,...);
-_CRTIMP int __cdecl _cwscanf_s(const wchar_t *_Format,...);
-_CRTIMP int __cdecl _cwscanf_s_l(const wchar_t *_Format,_locale_t _Locale,...);
-_SECIMP int __cdecl _vcwprintf_s (const wchar_t *_Format,va_list _ArgList);
 _SECIMP int __cdecl _cwprintf_s_l (const wchar_t *_Format,_locale_t 
_Locale,...);
+_SECIMP int __cdecl _vcwprintf_s (const wchar_t *_Format,va_list _ArgList);
 _SECIMP int __cdecl _vcwprintf_s_l (const wchar_t *_Format,_locale_t 
_Locale,va_list _ArgList);
+_CRTIMP int __cdecl _cwscanf_s(const wchar_t *_Format,...);
+_CRTIMP int __cdecl _cwscanf_s_l(const wchar_t *_Format,_locale_t _Locale,...);
 
 #ifdef __cplusplus
 }
-- 
2.51.0.windows.1

From e7a3ca8d3151da19c28dc6b70a18ea9dcd11a04d Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 20 Dec 2025 09:34:31 +0900
Subject: [PATCH 07/10] headers: conio.h: reorder declarations

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/conio.h | 58 +++++++++++++++++++++++------------
 1 file changed, 38 insertions(+), 20 deletions(-)

diff --git a/mingw-w64-headers/crt/conio.h b/mingw-w64-headers/crt/conio.h
index 44b6889ff..f59358a96 100644
--- a/mingw-w64-headers/crt/conio.h
+++ b/mingw-w64-headers/crt/conio.h
@@ -15,11 +15,33 @@
 extern "C" {
 #endif
 
+/**
+ * Functions to read/write strings from/to console.
+ */
+
   _CRTIMP char *__cdecl _cgets(char *_Buffer) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP int __cdecl _cputs(const char *_Str);
+
+/**
+ * Functions to read/write single characters from/to console.
+ */
+
+  _CRTIMP int __cdecl _kbhit(void);
   _CRTIMP int __cdecl _getch(void);
   _CRTIMP int __cdecl _getche(void);
-  _CRTIMP int __cdecl _kbhit(void);
+  _CRTIMP int __cdecl _putch(int _Ch);
+  _CRTIMP int __cdecl _ungetch(int _Ch);
+
+#if __MSVCRT_VERSION__ >= 0x800
+  _CRTIMP int __cdecl _getch_nolock(void);
+  _CRTIMP int __cdecl _getche_nolock(void);
+  _CRTIMP int __cdecl _putch_nolock(int _Ch);
+  _CRTIMP int __cdecl _ungetch_nolock(int _Ch);
+#endif
+
+/**
+ * Formatted console I/O functions.
+ */
 
 #ifdef _UCRT
   int __cdecl __conio_common_vcprintf(unsigned __int64 _Options, const char 
*_Format, _locale_t _Locale, va_list _ArgList);
@@ -60,7 +82,6 @@ extern "C" {
     __builtin_va_end(_ArgList);
     return _Ret;
   }
-
   __mingw_ovr int __cdecl _vcprintf_p(const char * __restrict__ 
_Format,va_list _ArgList)
   {
     return __conio_common_vcprintf_p(0, _Format, NULL, _ArgList);
@@ -100,19 +121,25 @@ extern "C" {
     __builtin_va_end(_ArgList);
     return _Ret;
   }
-#else
+#else /* !_UCRT */
   _CRTIMP int __cdecl _cprintf(const char * __restrict__ _Format,...);
-  _CRTIMP int __cdecl _cscanf(const char * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  _CRTIMP int __cdecl _cscanf_l(const char * __restrict__ _Format,_locale_t 
_Locale,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-
-  _CRTIMP int __cdecl _vcprintf(const char * __restrict__ _Format,va_list 
_ArgList);
-  _CRTIMP int __cdecl _cprintf_p(const char * __restrict__ _Format,...);
-  _CRTIMP int __cdecl _vcprintf_p(const char * __restrict__ _Format,va_list 
_ArgList);
   _CRTIMP int __cdecl _cprintf_l(const char * __restrict__ _Format,_locale_t 
_Locale,...);
-  _CRTIMP int __cdecl _vcprintf_l(const char * __restrict__ _Format,_locale_t 
_Locale,va_list _ArgList);
+  _CRTIMP int __cdecl _cprintf_p(const char * __restrict__ _Format,...);
   _CRTIMP int __cdecl _cprintf_p_l(const char * __restrict__ _Format,_locale_t 
_Locale,...);
+  _CRTIMP int __cdecl _vcprintf(const char * __restrict__ _Format,va_list 
_ArgList);
+  _CRTIMP int __cdecl _vcprintf_l(const char * __restrict__ _Format,_locale_t 
_Locale,va_list _ArgList);
+  _CRTIMP int __cdecl _vcprintf_p(const char * __restrict__ _Format,va_list 
_ArgList);
   _CRTIMP int __cdecl _vcprintf_p_l(const char * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList);
-#endif
+  _CRTIMP int __cdecl _cscanf(const char * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP int __cdecl _cscanf_l(const char * __restrict__ _Format,_locale_t 
_Locale,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+#endif /* _UCRT */
+
+/**
+ * Port I/O functions.
+ *
+ * These functions were removed from CRT in msvcr80.dll.
+ * They are still available in i386 system versions of msvcrt.dll.
+ */
 
 #if defined(_X86_) && !defined(__x86_64)
   int __cdecl _inp(unsigned short);
@@ -123,15 +150,6 @@ extern "C" {
   unsigned long __cdecl _outpd(unsigned short,unsigned long);
 #endif
 
-  _CRTIMP int __cdecl _putch(int _Ch);
-  _CRTIMP int __cdecl _ungetch(int _Ch);
-#if __MSVCRT_VERSION__ >= 0x800
-  _CRTIMP int __cdecl _getch_nolock(void);
-  _CRTIMP int __cdecl _getche_nolock(void);
-  _CRTIMP int __cdecl _putch_nolock(int _Ch);
-  _CRTIMP int __cdecl _ungetch_nolock(int _Ch);
-#endif
-
 #ifndef        NO_OLDNAMES
   char *__cdecl cgets(char *_Buffer) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
 
-- 
2.51.0.windows.1

From cb2372f5fca51ef33df85979fdd6bc8a4a43f121 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 20 Dec 2025 09:37:20 +0900
Subject: [PATCH 08/10] eaders: conio.h: move declarations guarded by
 NO_OLDNAMES closer to original declarations

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/conio.h | 100 +++++++++++++---------------------
 1 file changed, 38 insertions(+), 62 deletions(-)

diff --git a/mingw-w64-headers/crt/conio.h b/mingw-w64-headers/crt/conio.h
index f59358a96..98f066576 100644
--- a/mingw-w64-headers/crt/conio.h
+++ b/mingw-w64-headers/crt/conio.h
@@ -22,6 +22,11 @@ extern "C" {
   _CRTIMP char *__cdecl _cgets(char *_Buffer) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP int __cdecl _cputs(const char *_Str);
 
+#ifndef        NO_OLDNAMES
+  char *__cdecl cgets(char *_Buffer) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
+  int __cdecl cputs(const char *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
+#endif
+
 /**
  * Functions to read/write single characters from/to console.
  */
@@ -32,6 +37,14 @@ extern "C" {
   _CRTIMP int __cdecl _putch(int _Ch);
   _CRTIMP int __cdecl _ungetch(int _Ch);
 
+#ifndef        NO_OLDNAMES
+  int __cdecl kbhit(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
+  int __cdecl getch(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
+  int __cdecl getche(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
+  int __cdecl putch(int _Ch) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
+  int __cdecl ungetch(int _Ch) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
+#endif
+
 #if __MSVCRT_VERSION__ >= 0x800
   _CRTIMP int __cdecl _getch_nolock(void);
   _CRTIMP int __cdecl _getche_nolock(void);
@@ -121,6 +134,26 @@ extern "C" {
     __builtin_va_end(_ArgList);
     return _Ret;
   }
+#ifndef        NO_OLDNAMES
+  __mingw_ovr int __cdecl cprintf(const char * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_MSVC2005
+  {
+    __builtin_va_list _ArgList;
+    int _Ret;
+    __builtin_va_start(_ArgList, _Format);
+    _Ret = _vcprintf(_Format, _ArgList);
+    __builtin_va_end(_ArgList);
+    return _Ret;
+  }
+  __mingw_ovr int __cdecl cscanf(const char * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_MSVC2005
+  {
+    __builtin_va_list _ArgList;
+    int _Ret;
+    __builtin_va_start(_ArgList, _Format);
+    _Ret = __conio_common_vcscanf(0, _Format, NULL, _ArgList);
+    __builtin_va_end(_ArgList);
+    return _Ret;
+  }
+#endif /* NO_OLDNAMES */
 #else /* !_UCRT */
   _CRTIMP int __cdecl _cprintf(const char * __restrict__ _Format,...);
   _CRTIMP int __cdecl _cprintf_l(const char * __restrict__ _Format,_locale_t 
_Locale,...);
@@ -132,6 +165,10 @@ extern "C" {
   _CRTIMP int __cdecl _vcprintf_p_l(const char * __restrict__ 
_Format,_locale_t _Locale,va_list _ArgList);
   _CRTIMP int __cdecl _cscanf(const char * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP int __cdecl _cscanf_l(const char * __restrict__ _Format,_locale_t 
_Locale,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+#ifndef        NO_OLDNAMES
+  int __cdecl cprintf(const char * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_MSVC2005;
+  int __cdecl cscanf(const char * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_MSVC2005;
+#endif /* NO_OLDNAMES */
 #endif /* _UCRT */
 
 /**
@@ -148,73 +185,12 @@ extern "C" {
   int __cdecl _outp(unsigned short,int);
   unsigned short __cdecl _outpw(unsigned short,unsigned short);
   unsigned long __cdecl _outpd(unsigned short,unsigned long);
-#endif
-
 #ifndef        NO_OLDNAMES
-  char *__cdecl cgets(char *_Buffer) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
-
-#ifdef _UCRT
-  __mingw_ovr int __cdecl cprintf(const char * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_MSVC2005
-  {
-    __builtin_va_list _ArgList;
-    int _Ret;
-    __builtin_va_start(_ArgList, _Format);
-    _Ret = _vcprintf(_Format, _ArgList);
-    __builtin_va_end(_ArgList);
-    return _Ret;
-  }
-  __mingw_ovr int __cdecl cscanf(const char * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_MSVC2005
-  {
-    __builtin_va_list _ArgList;
-    int _Ret;
-    __builtin_va_start(_ArgList, _Format);
-    _Ret = __conio_common_vcscanf(0, _Format, NULL, _ArgList);
-    __builtin_va_end(_ArgList);
-    return _Ret;
-  }
-#else
-  int __cdecl cprintf(const char * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_MSVC2005;
-  int __cdecl cscanf(const char * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_MSVC2005;
-#endif
-  int __cdecl cputs(const char *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
-  int __cdecl getch(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
-  int __cdecl getche(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
-  int __cdecl kbhit(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
-  int __cdecl putch(int _Ch) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
-  int __cdecl ungetch(int _Ch) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
-
-#if (defined(_X86_) && !defined(__x86_64))
   int __cdecl inp(unsigned short) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
   unsigned short __cdecl inpw(unsigned short) 
__MINGW_ATTRIB_DEPRECATED_MSVC2005;
   int __cdecl outp(unsigned short,int) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
   unsigned short __cdecl outpw(unsigned short,unsigned short) 
__MINGW_ATTRIB_DEPRECATED_MSVC2005;
-#endif
-
-    /* __cpuid moved to intrin.h per msdn */
-    /* __inbyte moved to intrin.h per msdn */
-    /* __inbytestring moved to intrin.h per msdn */
-    /* __indword moved to intrin.h per msdn */
-    /* __indwordstring moved to intrin.h per msdn */
-    /* __inword moved to intrin.h per msdn */
-    /* __inwordstring moved to intrin.h per msdn */
-    /* __outbyte moved to intrin.h per msdn */
-    /* __outbytestring moved to intrin.h per msdn */
-    /* __outdword moved to intrin.h per msdn */
-    /* __outdwordstring moved to intrin.h per msdn */
-    /* __outword moved to intrin.h per msdn */
-    /* __outwordstring moved to intrin.h per msdn */
-    /* __readcr0 moved to intrin.h per msdn */
-    /* __readcr2 moved to intrin.h per msdn */
-    /* __readcr3 moved to intrin.h per msdn */
-    /* __readcr4 moved to intrin.h per msdn */
-    /* __readcr8 moved to intrin.h per msdn */
-    /* __readmsr moved to intrin.h per msdn */
-    /* __writecr0 moved to intrin.h per msdn */
-    /* __writecr2 moved to intrin.h per msdn */
-    /* __writecr3 moved to intrin.h per msdn */
-    /* __writecr4 moved to intrin.h per msdn */
-    /* __writecr8 moved to intrin.h per msdn */
-    /* __writemsr moved to intrin.h per msdn */
+#endif /* NO_OLDNAMES */
 #endif
 
 #ifdef __cplusplus
-- 
2.51.0.windows.1

From d899c1810dfed8299648498c754890f1f11af3a5 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 20 Dec 2025 09:38:01 +0900
Subject: [PATCH 09/10] headers: conio.h: update guard for port I/O functions

These functions were added in msvcrt40.dll and later were
removed in msvcr80.dll. They are still available in i386
system versions of msvcrt.dll.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/conio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mingw-w64-headers/crt/conio.h b/mingw-w64-headers/crt/conio.h
index 98f066576..5b9cdf0c2 100644
--- a/mingw-w64-headers/crt/conio.h
+++ b/mingw-w64-headers/crt/conio.h
@@ -178,7 +178,7 @@ extern "C" {
  * They are still available in i386 system versions of msvcrt.dll.
  */
 
-#if defined(_X86_) && !defined(__x86_64)
+#if (__MSVCRT_VERSION__ >= 0x0400 && __MSVCRT_VERSION__ < 0x0800) && 
defined(_M_IX86)
   int __cdecl _inp(unsigned short);
   unsigned short __cdecl _inpw(unsigned short);
   unsigned long __cdecl _inpd(unsigned short);
-- 
2.51.0.windows.1

From d253e033009993d176a86ba04f92facb4b197977 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 20 Dec 2025 09:53:33 +0900
Subject: [PATCH 10/10] headers: sec_api/conio_s.h: reorder declarations

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/sec_api/conio_s.h | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/mingw-w64-headers/crt/sec_api/conio_s.h 
b/mingw-w64-headers/crt/sec_api/conio_s.h
index 4eb03d200..3736d1525 100644
--- a/mingw-w64-headers/crt/sec_api/conio_s.h
+++ b/mingw-w64-headers/crt/sec_api/conio_s.h
@@ -22,15 +22,23 @@
 extern "C" {
 #endif
 
+/**
+ * Functions to read/write strings from/to console.
+ */
+
   _SECIMP errno_t __cdecl _cgets_s (char *_Buffer,size_t _Size,size_t 
*_SizeRead);
   __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1(errno_t, _cgets_s, char, _Buffer, 
size_t*, _SizeRead)
 
+/**
+ * Formatted console I/O functions.
+ */
+
   _SECIMP int __cdecl _cprintf_s (const char *_Format,...);
-  _CRTIMP int __cdecl _cscanf_s(const char *_Format,...);
-  _CRTIMP int __cdecl _cscanf_s_l(const char *_Format,_locale_t _Locale,...);
-  _SECIMP int __cdecl _vcprintf_s (const char *_Format,va_list _ArgList);
   _SECIMP int __cdecl _cprintf_s_l (const char *_Format,_locale_t _Locale,...);
+  _SECIMP int __cdecl _vcprintf_s (const char *_Format,va_list _ArgList);
   _SECIMP int __cdecl _vcprintf_s_l (const char *_Format,_locale_t 
_Locale,va_list _ArgList);
+  _CRTIMP int __cdecl _cscanf_s(const char *_Format,...);
+  _CRTIMP int __cdecl _cscanf_s_l(const char *_Format,_locale_t _Locale,...);
 
 #ifdef __cplusplus
 }
-- 
2.51.0.windows.1

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to