Functions _wcstoi64() and _wcstoui64() are available since msvcr70.dll and
are equivalent to C99 wcstoll() and wcstoull() functions. As mingw-w64
defines intmax_t and uintmax_t types 64-bit, same as (unsigned) long long,
these functions are equivalent also to C99 wcstoimax() and wcstoumax()
functions.

So for msvcr70+ import libraries define C99 function symbols wcstoll,
wcstoull, wcstoimax and wcstoumax as aliases to _wcstoi64 and _wcstoui64
symbols in the same way as are defined aliases to _strtoi64 and _strtoui64
symbols.

For previous versions use mingw-w64 implementation from wcstoimax.c and
wcstoumax.c files. Move them from libmingwex library to individual CRT
import libraries, to ensure that for msvcr70+ is used the native version
(and not the one from libmingwex).

This change mimics commits c52f1eb09901e038ceb7012730e7cf3395d65a78 and
4953f7746a9aca7ae065fa9aa77eb9d02d0ed752 but for wide-char functions.
---
 mingw-w64-crt/Makefile.am                    | 12 +++++++++++-
 mingw-w64-crt/def-include/crt-aliases.def.in |  8 ++++++++
 mingw-w64-crt/lib-common/msvcrt.def.in       |  6 +++---
 mingw-w64-crt/misc/wcstoimax.c               | 11 +++++++++++
 mingw-w64-crt/misc/wcstoumax.c               | 11 +++++++++++
 5 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index ef3d5011dd13..bd667356f7df 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -455,6 +455,8 @@ src_msvcrt32=\
   misc/strtoimax.c \
   misc/strtoumax.c \
   misc/wassert.c \
+  misc/wcstoimax.c \
+  misc/wcstoumax.c \
   stdio/_fstat64i32.c \
   stdio/_scprintf.c \
   stdio/_vscprintf.c
@@ -641,6 +643,8 @@ src_crtdll=\
   misc/strtoimax.c \
   misc/strtoumax.c \
   misc/wassert.c \
+  misc/wcstoimax.c \
+  misc/wcstoumax.c \
   stdio/_filelengthi64.c \
   stdio/_scprintf.c \
   stdio/_vscprintf.c \
@@ -685,6 +689,8 @@ src_msvcrt10=\
   misc/strtoimax.c \
   misc/strtoumax.c \
   misc/wassert.c \
+  misc/wcstoimax.c \
+  misc/wcstoumax.c \
   stdio/_filelengthi64.c \
   stdio/_scprintf.c \
   stdio/_vscprintf.c \
@@ -718,6 +724,8 @@ src_msvcrt20=\
   misc/strtoimax.c \
   misc/strtoumax.c \
   misc/wassert.c \
+  misc/wcstoimax.c \
+  misc/wcstoumax.c \
   stdio/_filelengthi64.c \
   stdio/_scprintf.c \
   stdio/_vscprintf.c \
@@ -746,6 +754,8 @@ src_msvcrt40=\
   misc/strtoimax.c \
   misc/strtoumax.c \
   misc/wassert.c \
+  misc/wcstoimax.c \
+  misc/wcstoumax.c \
   stdio/_scprintf.c \
   stdio/_vscprintf.c \
   stdio/atoll.c \
@@ -860,7 +870,7 @@ src_libmingwex=\
   misc/tdelete.c         misc/tdestroy.c            misc/tfind.c           \
   misc/tsearch.c         misc/twalk.c           \
   misc/wcsnlen.c         misc/wcstof.c          \
-  misc/wcstoimax.c       misc/wcstold.c             misc/wcstoumax.c        
misc/wctob.c                 misc/wctrans.c         \
+  misc/wcstold.c         misc/wctob.c               misc/wctrans.c         \
   misc/wctype.c          misc/wdirent.c             misc/winbs_uint64.c     
misc/winbs_ulong.c           misc/winbs_ushort.c    \
   misc/wmemchr.c         misc/wmemcmp.c             misc/wmemcpy.c          
misc/wmemmove.c              misc/wmempcpy.c        \
   misc/wmemset.c         misc/ftw.c                 misc/ftw64.c            
misc/mingw-access.c          \
diff --git a/mingw-w64-crt/def-include/crt-aliases.def.in 
b/mingw-w64-crt/def-include/crt-aliases.def.in
index c0bcef85e131..ba4dfb908fe4 100644
--- a/mingw-w64-crt/def-include/crt-aliases.def.in
+++ b/mingw-w64-crt/def-include/crt-aliases.def.in
@@ -289,6 +289,10 @@ strtoll == _strtoi64
 strtoull == _strtoui64
 strtoimax == _strtoi64
 strtoumax == _strtoui64
+wcstoll == _wcstoi64
+wcstoull == _wcstoui64
+wcstoimax == _wcstoi64
+wcstoumax == _wcstoui64
 #endif
 
 #ifdef WITH_STRTO64_L_ALIAS
@@ -296,6 +300,10 @@ _strtoll_l == _strtoi64_l
 _strtoull_l == _strtoui64_l
 _strtoimax_l == _strtoi64_l
 _strtoumax_l == _strtoui64_l
+_wcstoll_l == _wcstoi64_l
+_wcstoull_l == _wcstoui64_l
+_wcstoimax_l == _wcstoi64_l
+_wcstoumax_l == _wcstoui64_l
 #endif
 
 ; This is list of find symbol aliases, every CRT library has either find 
symbols with SIZE suffix or without them
diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in 
b/mingw-w64-crt/lib-common/msvcrt.def.in
index 1ae45480cb0e..60e901f020f1 100644
--- a/mingw-w64-crt/lib-common/msvcrt.def.in
+++ b/mingw-w64-crt/lib-common/msvcrt.def.in
@@ -1224,8 +1224,8 @@ _ungetwch
 F_NON_I386(_vscprintf) ; i386 _vscprintf replaced by emu
 _vscwprintf
 _wcserror
-_wcstoi64
-_wcstoui64
+F_NON_I386(_wcstoi64) ; i386 _wcstoi64 replaced by emu
+F_NON_I386(_wcstoui64) ; i386 _wcstoui64 replaced by emu
 _wtof
 
 ; These symbols were added in Windows Server 2003 OS system version of 
msvcrt.dll
@@ -1919,7 +1919,7 @@ F_I386(_libm_sse2_tan_precise)
 #ifndef DEF_I386
 ; i386 llabs and imaxabs alias provided by emu
 #define WITH_LLABS_ALIAS
-; i386 strtoll, strtoull, strtoimax and strtoumax alias provided by emu
+; i386 strtoll, strtoull, strtoimax, strtoumax, wcstoll, wcstoull, wcstoimax 
and wcstoumax aliases provided by emu
 #define WITH_STRTO64_ALIAS
 #endif
 #include "crt-aliases.def.in"
diff --git a/mingw-w64-crt/misc/wcstoimax.c b/mingw-w64-crt/misc/wcstoimax.c
index 99e97b92144c..86c7347bb6b9 100644
--- a/mingw-w64-crt/misc/wcstoimax.c
+++ b/mingw-w64-crt/misc/wcstoimax.c
@@ -33,6 +33,7 @@
 #define valid(n, b)    ((n) >= 0 && (n) < (b))
 
 intmax_t
+__cdecl
 wcstoimax(const wchar_t * __restrict__ nptr, wchar_t ** __restrict__ endptr, 
int base)
        {
        register uintmax_t      accum;  /* accumulates converted value */
@@ -116,6 +117,16 @@ wcstoimax(const wchar_t * __restrict__ nptr, wchar_t ** 
__restrict__ endptr, int
        else
                return (intmax_t)(minus ? -accum : accum);
        }
+intmax_t (__cdecl *__MINGW_IMP_SYMBOL(wcstoimax))(const wchar_t * 
__restrict__, wchar_t ** __restrict__, int) = wcstoimax;
 
 long long __attribute__ ((alias ("wcstoimax")))
+__cdecl
 wcstoll (const wchar_t* __restrict__ nptr, wchar_t ** __restrict__ endptr, int 
base);
+extern long long __attribute__ ((alias 
(__MINGW64_STRINGIFY(__MINGW_IMP_SYMBOL(wcstoimax)))))
+(__cdecl *__MINGW_IMP_SYMBOL(wcstoll))(const wchar_t * __restrict__, wchar_t 
** __restrict__, int);
+
+long long __attribute__ ((alias ("wcstoimax")))
+__cdecl
+_wcstoi64 (const wchar_t* __restrict__ nptr, wchar_t ** __restrict__ endptr, 
int base);
+extern long long __attribute__ ((alias 
(__MINGW64_STRINGIFY(__MINGW_IMP_SYMBOL(wcstoimax)))))
+(__cdecl *__MINGW_IMP_SYMBOL(_wcstoi64))(const wchar_t * __restrict__, wchar_t 
** __restrict__, int);
diff --git a/mingw-w64-crt/misc/wcstoumax.c b/mingw-w64-crt/misc/wcstoumax.c
index 97f2c3083372..ad73cb46a11b 100644
--- a/mingw-w64-crt/misc/wcstoumax.c
+++ b/mingw-w64-crt/misc/wcstoumax.c
@@ -33,6 +33,7 @@
 #define valid(n, b)    ((n) >= 0 && (n) < (b))
 
 uintmax_t
+__cdecl
 wcstoumax(const wchar_t * __restrict__ nptr, wchar_t ** __restrict__ endptr, 
int base)
        {
        register uintmax_t      accum;  /* accumulates converted value */
@@ -110,6 +111,16 @@ wcstoumax(const wchar_t * __restrict__ nptr, wchar_t ** 
__restrict__ endptr, int
        else
                return minus ? -accum : accum;  /* (yes!) */
        }
+uintmax_t (__cdecl *__MINGW_IMP_SYMBOL(wcstoumax))(const wchar_t * 
__restrict__, wchar_t ** __restrict__, int) = wcstoumax;
 
 unsigned long long __attribute__ ((alias ("wcstoumax")))
+__cdecl
 wcstoull (const wchar_t* __restrict__ nptr, wchar_t ** __restrict__ endptr, 
int base);
+extern unsigned long long __attribute__ ((alias 
(__MINGW64_STRINGIFY(__MINGW_IMP_SYMBOL(wcstoumax)))))
+(__cdecl *__MINGW_IMP_SYMBOL(wcstoull))(const wchar_t * __restrict__, wchar_t 
** __restrict__, int);
+
+unsigned long long __attribute__ ((alias ("wcstoumax")))
+__cdecl
+_wcstoui64 (const wchar_t* __restrict__ nptr, wchar_t ** __restrict__ endptr, 
int base);
+extern unsigned long long __attribute__ ((alias 
(__MINGW64_STRINGIFY(__MINGW_IMP_SYMBOL(wcstoumax)))))
+(__cdecl *__MINGW_IMP_SYMBOL(_wcstoui64))(const wchar_t * __restrict__, 
wchar_t ** __restrict__, int);
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to