crt: Split UCRT __ms_fwprintf() into separate file

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Pali Rohár 2024-09-28 00:15:28 +02:00 committed by Martin Storsjö
parent 200b20f657
commit 51f5fd310f
3 changed files with 25 additions and 16 deletions

View File

@ -370,6 +370,7 @@ src_ucrtbase=\
misc/ucrt-access.c \
stdio/ucrt_fprintf.c \
stdio/ucrt_fscanf.c \
stdio/ucrt_ms_fwprintf.c \
stdio/ucrt_fwprintf.c \
stdio/ucrt_printf.c \
stdio/ucrt_scanf.c \

View File

@ -29,9 +29,6 @@
// to get rid of the _CRTIMP in headers).
void __cdecl __MINGW_ATTRIB_NORETURN _amsg_exit(int ret);
int __cdecl __ms_fwprintf(FILE *, const wchar_t *, ...);
void __cdecl __MINGW_ATTRIB_NORETURN _amsg_exit(int ret) {
fprintf(stderr, "runtime error %d\n", ret);
_exit(255);
@ -70,22 +67,9 @@ void __cdecl tzset(void)
_tzset();
}
// This is called for wchar cases with __USE_MINGW_ANSI_STDIO enabled (where the
// char case just uses fputc).
int __cdecl __ms_fwprintf(FILE *file, const wchar_t *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
ret = __stdio_common_vfwprintf(_CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS, file, fmt, NULL, ap);
va_end(ap);
return ret;
}
// Dummy/unused __imp_ wrappers, to make GNU ld not autoexport these symbols.
void __cdecl (*__MINGW_IMP_SYMBOL(_amsg_exit))(int) = _amsg_exit;
void __cdecl (*__MINGW_IMP_SYMBOL(tzset))(void) = tzset;
int __cdecl (*__MINGW_IMP_SYMBOL(__ms_fwprintf))(FILE *, const wchar_t *, ...) = __ms_fwprintf;
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

View File

@ -0,0 +1,24 @@
/**
* 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>
// This is called for wchar cases with __USE_MINGW_ANSI_STDIO enabled (where the
// char case just uses fputc).
int __cdecl __ms_fwprintf(FILE *file, const wchar_t *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
ret = __stdio_common_vfwprintf(_CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS, file, fmt, NULL, ap);
va_end(ap);
return ret;
}
int __cdecl (*__MINGW_IMP_SYMBOL(__ms_fwprintf))(FILE *, const wchar_t *, ...) = __ms_fwprintf;