crt: Deinline UCRT _swprintf() and _vswprintf() functions and define import symbols for them This allows to reference _swprintf() and _vswprintf() functions for UCRT build via their symbols, like for msvcrt builds. This change is needed to allow to use __MINGW_ASM_CALL(_swprintf). Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index e08173d..a24221d 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am
@@ -417,9 +417,11 @@ stdio/ucrt__snprintf.c \ stdio/ucrt__snscanf.c \ stdio/ucrt__snwprintf.c \ + stdio/ucrt__swprintf.c \ stdio/ucrt__vscprintf.c \ stdio/ucrt__vsnprintf.c \ stdio/ucrt__vsnwprintf.c \ + stdio/ucrt__vswprintf.c \ stdio/ucrt_fprintf.c \ stdio/ucrt_fscanf.c \ stdio/ucrt_fwprintf.c \
diff --git a/mingw-w64-crt/stdio/ucrt__swprintf.c b/mingw-w64-crt/stdio/ucrt__swprintf.c new file mode 100644 index 0000000..c39c4f0 --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt__swprintf.c
@@ -0,0 +1,21 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT +#include <stdio.h> +#include <stdarg.h> + +int __cdecl _swprintf(wchar_t * restrict dest, const wchar_t * restrict format, ...) +{ + int ret; + va_list args; + va_start(args, format); + ret = __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, dest, (size_t)-1, format, NULL, args); + va_end(args); + return ret; +} +int __cdecl (*__MINGW_IMP_SYMBOL(_swprintf))(wchar_t * restrict, const wchar_t * restrict, ...) = _swprintf;
diff --git a/mingw-w64-crt/stdio/ucrt__vswprintf.c b/mingw-w64-crt/stdio/ucrt__vswprintf.c new file mode 100644 index 0000000..71c18e1 --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt__vswprintf.c
@@ -0,0 +1,15 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT +#include <stdio.h> + +int __cdecl _vswprintf(wchar_t * restrict dest, const wchar_t * restrict format, va_list args) +{ + return __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, dest, (size_t)-1, format, NULL, args); +} +int __cdecl (*__MINGW_IMP_SYMBOL(_vswprintf))(wchar_t * restrict, const wchar_t * restrict, va_list) = _vswprintf;
diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h index 91d617f..14e14e5 100644 --- a/mingw-w64-headers/crt/stdio.h +++ b/mingw-w64-headers/crt/stdio.h
@@ -1186,21 +1186,8 @@ int __cdecl vsnwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, va_list arg); #endif - __mingw_ovr - int __cdecl _swprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,...) - { - __builtin_va_list __ap; - int __ret; - __builtin_va_start(__ap, _Format); - __ret = __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Dest, (size_t)-1, _Format, NULL, __ap); - __builtin_va_end(__ap); - return __ret; - } - __mingw_ovr - int __cdecl _vswprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,va_list _Args) - { - return __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Dest, (size_t)-1, _Format, NULL, _Args); - } + _CRTIMP int __cdecl _swprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,...); + _CRTIMP int __cdecl _vswprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,va_list _Args); __mingw_ovr int __cdecl _vscwprintf(const wchar_t * __restrict__ _Format, va_list _ArgList)
diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h index c72530c..809d497 100644 --- a/mingw-w64-headers/crt/wchar.h +++ b/mingw-w64-headers/crt/wchar.h
@@ -828,10 +828,7 @@ { return _vswprintf_c_l(_DstBuf, _MaxCount, _Format, _Locale, _ArgList); } - __mingw_ovr int __cdecl _vswprintf(wchar_t *_DstBuf, const wchar_t *_Format, va_list _ArgList) - { - return _vswprintf_c_l(_DstBuf, (size_t)-1, _Format, NULL, _ArgList); - } + _CRTIMP int __cdecl _vswprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,va_list _Args); __mingw_ovr int __cdecl _swprintf_c_l(wchar_t *_DstBuf, size_t _MaxCount, const wchar_t *_Format, _locale_t _Locale, ...) { __builtin_va_list _ArgList; @@ -850,15 +847,7 @@ __builtin_va_end(_ArgList); return _Ret; } - __mingw_ovr int __cdecl _swprintf(wchar_t *_DstBuf, const wchar_t *_Format, ...) - { - __builtin_va_list _ArgList; - int _Ret; - __builtin_va_start(_ArgList, _Format); - _Ret = _vswprintf_c_l(_DstBuf, (size_t)-1, _Format, NULL, _ArgList); - __builtin_va_end(_ArgList); - return _Ret; - } + _CRTIMP int __cdecl _swprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,...); #else /* _UCRT */ _CRTIMP int __cdecl _fwprintf_p(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...); _CRTIMP int __cdecl _wprintf_p(const wchar_t * __restrict__ _Format,...);