This should help build system checks, that only test for the function
by linking, realize that the function actually does exist.

Signed-off-by: Martin Storsjö <[email protected]>
---
 mingw-w64-crt/Makefile.am         |  1 +
 mingw-w64-crt/misc/ucrt_mbsinit.c | 14 ++++++++++++++
 mingw-w64-headers/crt/wchar.h     |  9 +++------
 3 files changed, 18 insertions(+), 6 deletions(-)
 create mode 100644 mingw-w64-crt/misc/ucrt_mbsinit.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 011692eb9..8f3cb22f7 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -225,6 +225,7 @@ src_msvcrt=\
 
 src_ucrtbase=\
   crt/ucrtbase_compat.c \
+  misc/ucrt_mbsinit.c \
   stdio/ucrt_fprintf.c \
   stdio/ucrt_fwprintf.c \
   stdio/ucrt_printf.c \
diff --git a/mingw-w64-crt/misc/ucrt_mbsinit.c 
b/mingw-w64-crt/misc/ucrt_mbsinit.c
new file mode 100644
index 000000000..5aea949f6
--- /dev/null
+++ b/mingw-w64-crt/misc/ucrt_mbsinit.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.
+ */
+
+#define __CRT__NO_INLINE
+#define _UCRT
+#include <wchar.h>
+
+int __cdecl mbsinit(const mbstate_t *_P)
+{
+  return (!_P || _P->_Wchar == 0);
+}
diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h
index 3fde2a6fb..1d7db3783 100644
--- a/mingw-w64-headers/crt/wchar.h
+++ b/mingw-w64-headers/crt/wchar.h
@@ -1441,12 +1441,7 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const 
wchar_t *__format, __builti
   wchar_t * __cdecl wmempcpy (wchar_t *_Dst, const wchar_t *_Src, size_t 
_Size);
   wchar_t *__cdecl wmemmove(wchar_t *s1, const wchar_t *s2, size_t n) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   int __cdecl fwide(FILE *stream,int mode);
-#if defined(_UCRT) || defined(__LARGE_MBSTATE_T)
-  /* With UCRT, mbsinit is only available as inline. */
-  __mingw_static_ovr int __cdecl mbsinit(const mbstate_t *_P) { return (!_P || 
_P->_Wchar == 0); }
-#else
   int __cdecl mbsinit(const mbstate_t *ps);
-#endif
   __MINGW_EXTENSION long long __cdecl wcstoll(const wchar_t * __restrict__ 
nptr,wchar_t ** __restrict__ endptr, int base);
   __MINGW_EXTENSION unsigned long long __cdecl wcstoull(const wchar_t * 
__restrict__ nptr,wchar_t ** __restrict__ endptr, int base);
 #endif /* __NO_ISOCEXT */
@@ -1455,7 +1450,9 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const 
wchar_t *__format, __builti
   void *__cdecl memcpy(void * __restrict__ _Dst,const void * __restrict__ 
_Src,size_t _MaxCount) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 #ifndef __CRT__NO_INLINE
   __CRT_INLINE int __cdecl fwide(FILE *_F,int _M) { (void)_F; return (_M); }
-#if !defined(_UCRT) && !defined(__LARGE_MBSTATE_T)
+#if defined(_UCRT) || defined(__LARGE_MBSTATE_T)
+  __CRT_INLINE int __cdecl mbsinit(const mbstate_t *_P) { return (!_P || 
_P->_Wchar == 0); }
+#else
   __CRT_INLINE int __cdecl mbsinit(const mbstate_t *_P) { return (!_P || 
*_P==0); }
 #endif
   __CRT_INLINE _CONST_RETURN wchar_t *__cdecl wmemchr(const wchar_t 
*_S,wchar_t _C,size_t _N) {
-- 
2.17.1



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

Reply via email to