Now these functions should respect UCRT stdio flags set by assigning to _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, so there's no need to keep them inline. Making them non-inline helps referring to them via a plain symbol, using __MINGW_ASM_CALL().
fwprintf was already non-inline (since the start), and since 30c0b623dbaf9dcc218c9068625f5e8dddd57aab we no longer provided an inline version of it. Signed-off-by: Martin Storsjö <[email protected]> --- mingw-w64-crt/Makefile.am | 7 +++ mingw-w64-crt/stdio/ucrt_snwprintf.c | 21 +++++++ mingw-w64-crt/stdio/ucrt_swprintf.c | 31 +++++++++++ mingw-w64-crt/stdio/ucrt_vfwprintf.c | 15 +++++ mingw-w64-crt/stdio/ucrt_vsnwprintf.c | 16 ++++++ mingw-w64-crt/stdio/ucrt_vswprintf.c | 28 ++++++++++ mingw-w64-crt/stdio/ucrt_vwprintf.c | 15 +++++ mingw-w64-crt/stdio/ucrt_wprintf.c | 25 +++++++++ mingw-w64-headers/crt/stdio.h | 79 +++----------------------- mingw-w64-headers/crt/wchar.h | 80 +++------------------------ 10 files changed, 172 insertions(+), 145 deletions(-) create mode 100644 mingw-w64-crt/stdio/ucrt_snwprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt_swprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt_vfwprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt_vsnwprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt_vswprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt_vwprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt_wprintf.c diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index 5be85382f..ad8bb94f0 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -418,15 +418,22 @@ src_ucrtbase=\ stdio/ucrt_printf.c \ stdio/ucrt_scanf.c \ stdio/ucrt_snprintf.c \ + stdio/ucrt_snwprintf.c \ stdio/ucrt_sprintf.c \ stdio/ucrt_sscanf.c \ + stdio/ucrt_swprintf.c \ stdio/ucrt_vfprintf.c \ stdio/ucrt_vfscanf.c \ + stdio/ucrt_vfwprintf.c \ stdio/ucrt_vprintf.c \ stdio/ucrt_vscanf.c \ stdio/ucrt_vsnprintf.c \ + stdio/ucrt_vsnwprintf.c \ stdio/ucrt_vsprintf.c \ + stdio/ucrt_vswprintf.c \ stdio/ucrt_vsscanf.c \ + stdio/ucrt_vwprintf.c \ + stdio/ucrt_wprintf.c \ string/ucrt__wcstok.c # Files included in libucrtapp.a diff --git a/mingw-w64-crt/stdio/ucrt_snwprintf.c b/mingw-w64-crt/stdio/ucrt_snwprintf.c new file mode 100644 index 000000000..19ed6940e --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt_snwprintf.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> + +int __cdecl snwprintf (wchar_t * __restrict__ s, size_t n, 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 | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, s, n, format, NULL, __ap); + __builtin_va_end(__ap); + return __ret; +} + +int __cdecl (*__MINGW_IMP_SYMBOL(snwprintf))(wchar_t *__restrict__, size_t, const wchar_t *__restrict__, ...) = snwprintf; diff --git a/mingw-w64-crt/stdio/ucrt_swprintf.c b/mingw-w64-crt/stdio/ucrt_swprintf.c new file mode 100644 index 000000000..46b29a18e --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt_swprintf.c @@ -0,0 +1,31 @@ +/** + * 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 swprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,...) +{ + __builtin_va_list __ap; + int __ret; + /* + * __stdio_common_vswprintf() for case _Dest == NULL and _Count == 0 and + * without _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR option, is + * executed in "standard snprintf behavior" and returns number of (wide) + * chars required to allocate. For all other cases it is executed in a way + * that returns negative value on error. But C95+ compliant swprintf() for + * case _Count == 0 returns negative value, so handle this case specially. + */ + if (_Dest == NULL && _Count == 0) + return -1; + __builtin_va_start(__ap, _Format); + __ret = __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Dest, _Count, _Format, NULL, __ap); + __builtin_va_end(__ap); + return __ret < 0 ? -1 : __ret; +} + +int __cdecl (*__MINGW_IMP_SYMBOL(swprintf))(wchar_t *__restrict__, size_t, const wchar_t *__restrict__, ...) = swprintf; diff --git a/mingw-w64-crt/stdio/ucrt_vfwprintf.c b/mingw-w64-crt/stdio/ucrt_vfwprintf.c new file mode 100644 index 000000000..4dbc47f73 --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt_vfwprintf.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 vfwprintf(FILE * __restrict__ _File, const wchar_t * __restrict__ _Format, va_list _ArgList) +{ + return __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _File, _Format, NULL, _ArgList); +} +int __cdecl (*__MINGW_IMP_SYMBOL(vfwprintf))(FILE *__restrict__, const wchar_t *__restrict__, va_list) = vfwprintf; diff --git a/mingw-w64-crt/stdio/ucrt_vsnwprintf.c b/mingw-w64-crt/stdio/ucrt_vsnwprintf.c new file mode 100644 index 000000000..e30df1a6b --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt_vsnwprintf.c @@ -0,0 +1,16 @@ +/** + * 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 vsnwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, va_list arg) +{ + return __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, s, n, format, NULL, arg); +} + +int __cdecl (*__MINGW_IMP_SYMBOL(vsnwprintf))(wchar_t *__restrict__, size_t, const wchar_t *__restrict__, va_list) = vsnwprintf; diff --git a/mingw-w64-crt/stdio/ucrt_vswprintf.c b/mingw-w64-crt/stdio/ucrt_vswprintf.c new file mode 100644 index 000000000..ad0196d8b --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt_vswprintf.c @@ -0,0 +1,28 @@ +/** + * 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,size_t _Count,const wchar_t * __restrict__ _Format,va_list _Args) +{ + int __ret; + /* + * __stdio_common_vswprintf() for case _Dest == NULL and _Count == 0 and + * without _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR option, is + * executed in "standard snprintf behavior" and returns number of (wide) + * chars required to allocate. For all other cases it is executed in a way + * that returns negative value on error. But C95+ compliant vswprintf() for + * case _Count == 0 returns negative value, so handle this case specially. + */ + if (_Dest == NULL && _Count == 0) + return -1; + __ret = __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Dest, _Count, _Format, NULL, _Args); + return __ret < 0 ? -1 : __ret; +} + +int __cdecl (*__MINGW_IMP_SYMBOL(vswprintf))(wchar_t *__restrict__, size_t, const wchar_t *__restrict__, va_list) = vswprintf; diff --git a/mingw-w64-crt/stdio/ucrt_vwprintf.c b/mingw-w64-crt/stdio/ucrt_vwprintf.c new file mode 100644 index 000000000..750702040 --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt_vwprintf.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 vwprintf(const wchar_t * __restrict__ _Format, va_list _ArgList) +{ + return __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, _Format, NULL, _ArgList); +} +int __cdecl (*__MINGW_IMP_SYMBOL(vwprintf))(const wchar_t *__restrict__, va_list) = vwprintf; diff --git a/mingw-w64-crt/stdio/ucrt_wprintf.c b/mingw-w64-crt/stdio/ucrt_wprintf.c new file mode 100644 index 000000000..1e2154fd8 --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt_wprintf.c @@ -0,0 +1,25 @@ +/** + * 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 <stdarg.h> +#include <stdio.h> + +int __cdecl wprintf(const wchar_t *fmt, ...); + +int __cdecl wprintf(const wchar_t *fmt, ...) +{ + va_list ap; + int ret; + va_start(ap, fmt); + ret = __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, fmt, NULL, ap); + va_end(ap); + return ret; +} + +int __cdecl (*__MINGW_IMP_SYMBOL(wprintf))(const wchar_t *, ...) = wprintf; diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h index 7e0d3d917..bc24cce39 100644 --- a/mingw-w64-headers/crt/stdio.h +++ b/mingw-w64-headers/crt/stdio.h @@ -1113,26 +1113,9 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti } int __cdecl fwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...); - __mingw_ovr - int __cdecl wprintf(const wchar_t * __restrict__ _Format,...) - { - __builtin_va_list __ap; - int __ret; - __builtin_va_start(__ap, _Format); - __ret = __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, _Format, NULL, __ap); - __builtin_va_end(__ap); - return __ret; - } - __mingw_ovr - int __cdecl vfwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,va_list _ArgList) - { - return __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _File, _Format, NULL, _ArgList); - } - __mingw_ovr - int __cdecl vwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList) - { - return __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, _Format, NULL, _ArgList); - } + int __cdecl wprintf(const wchar_t * __restrict__ _Format,...); + int __cdecl vfwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,va_list _ArgList); + int __cdecl vwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList); #else int __cdecl fwscanf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; @@ -1203,59 +1186,11 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti int __cdecl _vsnwprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,va_list _Args) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; #if __USE_MINGW_ANSI_STDIO == 0 - __mingw_ovr - int __cdecl swprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,...) - { - __builtin_va_list __ap; - int __ret; - /* - * __stdio_common_vswprintf() for case _Dest == NULL and _Count == 0 and - * without _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR option, is - * executed in "standard snprintf behavior" and returns number of (wide) - * chars required to allocate. For all other cases it is executed in a way - * that returns negative value on error. But C95+ compliant swprintf() for - * case _Count == 0 returns negative value, so handle this case specially. - */ - if (_Dest == NULL && _Count == 0) - return -1; - __builtin_va_start(__ap, _Format); - __ret = __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Dest, _Count, _Format, NULL, __ap); - __builtin_va_end(__ap); - return __ret < 0 ? -1 : __ret; - } - __mingw_ovr - int __cdecl vswprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,va_list _Args) - { - int __ret; - /* - * __stdio_common_vswprintf() for case _Dest == NULL and _Count == 0 and - * without _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR option, is - * executed in "standard snprintf behavior" and returns number of (wide) - * chars required to allocate. For all other cases it is executed in a way - * that returns negative value on error. But C95+ compliant vswprintf() for - * case _Count == 0 returns negative value, so handle this case specially. - */ - if (_Dest == NULL && _Count == 0) - return -1; - __ret = __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Dest, _Count, _Format, NULL, _Args); - return __ret < 0 ? -1 : __ret; - } + int __cdecl swprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,...); + int __cdecl vswprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,va_list _Args); - __mingw_ovr - int __cdecl snwprintf (wchar_t * __restrict__ s, size_t n, 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 | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, s, n, format, NULL, __ap); - __builtin_va_end(__ap); - return __ret; - } - __mingw_ovr - int __cdecl vsnwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, va_list arg) - { - return __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, s, n, format, NULL, arg); - } + int __cdecl snwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, ...); + int __cdecl vsnwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, va_list arg); #endif __mingw_ovr diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h index a5821e4bd..6c1873420 100644 --- a/mingw-w64-headers/crt/wchar.h +++ b/mingw-w64-headers/crt/wchar.h @@ -484,64 +484,12 @@ __MINGW_ASM_CALL(__mingw_vsnwprintf); } int __cdecl fwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...); - __mingw_ovr - int __cdecl wprintf(const wchar_t * __restrict__ _Format,...) - { - __builtin_va_list __ap; - int __ret; - __builtin_va_start(__ap, _Format); - __ret = __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, _Format, NULL, __ap); - __builtin_va_end(__ap); - return __ret; - } - __mingw_ovr - int __cdecl vfwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,va_list _ArgList) - { - return __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _File, _Format, NULL, _ArgList); - } - __mingw_ovr - int __cdecl vwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList) - { - return __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, _Format, NULL, _ArgList); - } + int __cdecl wprintf(const wchar_t * __restrict__ _Format,...); + int __cdecl vfwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,va_list _ArgList); + int __cdecl vwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList); - __mingw_ovr - int __cdecl swprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,...) - { - __builtin_va_list __ap; - int __ret; - /* - * __stdio_common_vswprintf() for case _Dest == NULL and _Count == 0 and - * without _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR option, is - * executed in "standard snprintf behavior" and returns number of (wide) - * chars required to allocate. For all other cases it is executed in a way - * that returns negative value on error. But C95+ compliant swprintf() for - * case _Count == 0 returns negative value, so handle this case specially. - */ - if (_Dest == NULL && _Count == 0) - return -1; - __builtin_va_start(__ap, _Format); - __ret = __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Dest, _Count, _Format, NULL, __ap); - __builtin_va_end(__ap); - return __ret < 0 ? -1 : __ret; - } - __mingw_ovr - int __cdecl vswprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,va_list _Args) - { - int __ret; - /* - * __stdio_common_vswprintf() for case _Dest == NULL and _Count == 0 and - * without _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR option, is - * executed in "standard snprintf behavior" and returns number of (wide) - * chars required to allocate. For all other cases it is executed in a way - * that returns negative value on error. But C95+ compliant vswprintf() for - * case _Count == 0 returns negative value, so handle this case specially. - */ - if (_Dest == NULL && _Count == 0) - return -1; - __ret = __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Dest, _Count, _Format, NULL, _Args); - return __ret < 0 ? -1 : __ret; - } + int __cdecl swprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,...); + int __cdecl vswprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,va_list _Args); #else int __cdecl fwscanf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; @@ -628,22 +576,8 @@ __MINGW_ASM_CALL(__mingw_vsnwprintf); } #if __USE_MINGW_ANSI_STDIO == 0 - __mingw_ovr - int snwprintf (wchar_t * __restrict__ s, size_t n, 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 | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, s, n, format, NULL, __ap); - __builtin_va_end(__ap); - return __ret < 0 ? -1 : __ret; - } - __mingw_ovr - int __cdecl vsnwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, va_list arg) - { - int __ret = __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, s, n, format, NULL, arg); - return __ret < 0 ? -1 : __ret; - } + int snwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, ...); + int __cdecl vsnwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, va_list arg); #endif #else -- 2.43.0 _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
