Before b1634783c20dbae, we never used ___mb_cur_max_func() (available in
msvcrt.dll since XP). Since that commit (done to unify things between
msvcrt and ucrt), any use of MB_CUR_MAX uses this function.

Therefore, make libmsvcrt-os.a for i386 provide this function statically,
using the __mb_cur_max data symbol, to restore compatibility as it was
before this commit.

Signed-off-by: Martin Storsjö <[email protected]>
---
Run autoreconf in mingw-w64-crt after applying.
---
 mingw-w64-crt/Makefile.am               |  1 +
 mingw-w64-crt/lib-common/msvcrt.def.in  |  5 ++++-
 mingw-w64-crt/misc/___mb_cur_max_func.c | 18 ++++++++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 mingw-w64-crt/misc/___mb_cur_max_func.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index b848f9c18..726cc4833 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -233,6 +233,7 @@ src_ucrtbase=\
 src_msvcrt32=\
   $(src_msvcrt) \
   math/x86/_copysignf.c \
+  misc/___mb_cur_max_func.c \
   misc/lc_locale_func.c \
   misc/wassert.c
 
diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in 
b/mingw-w64-crt/lib-common/msvcrt.def.in
index 4e7410c6a..2883c1dba 100644
--- a/mingw-w64-crt/lib-common/msvcrt.def.in
+++ b/mingw-w64-crt/lib-common/msvcrt.def.in
@@ -260,7 +260,10 @@ __STRINGTOLD
 F_NON_I386(___lc_codepage_func)
 ___lc_collate_cp_func
 ___lc_handle_func
-___mb_cur_max_func
+; ___mb_cur_max_func exists (on all archs) since XP. Earlier, this function 
was never used, but the __mb_cur_max data symbol was accessed instead.
+; For i386 we provide this function as a statically linked helper, that uses
+; __mb_cur_max, to avoid forcing the XP dependency here.
+F_NON_I386(___mb_cur_max_func)
 F_X86_ANY(___setlc_active_func)
 F_X86_ANY(___unguarded_readlc_active_add_func)
 __argc DATA
diff --git a/mingw-w64-crt/misc/___mb_cur_max_func.c 
b/mingw-w64-crt/misc/___mb_cur_max_func.c
new file mode 100644
index 000000000..61dcdb7a6
--- /dev/null
+++ b/mingw-w64-crt/misc/___mb_cur_max_func.c
@@ -0,0 +1,18 @@
+/**
+ * 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 <_mingw.h>
+
+extern int* __MINGW_IMP_SYMBOL(__mb_cur_max);
+
+int __cdecl ___mb_cur_max_func(void);
+int __cdecl ___mb_cur_max_func(void)
+{
+    return *__MINGW_IMP_SYMBOL(__mb_cur_max);
+}
+
+typedef int __cdecl (*_f___mb_cur_max_func)(void);
+_f___mb_cur_max_func __MINGW_IMP_SYMBOL(___mb_cur_max_func) = 
___mb_cur_max_func;
-- 
2.17.1



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

Reply via email to