For non-msvcrtos builds are global variables __MINGW_IMP_SYMBOL(_scprintf) __MINGW_IMP_SYMBOL(_vscprintf) not changing, they are constant.
So define _scprintf and _vscprintf functions as direct alias to emu_scprintf and emu_vscprintf functions instead of via indirect unconditional jump or function call. This also simplifies _scprintf definition for non-msvcrtos builds as it reduces usage of inline assembly code. There is no change for msvcrtos build. --- mingw-w64-crt/stdio/_scprintf.c | 13 ++----------- mingw-w64-crt/stdio/_vscprintf.c | 7 ++++--- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/mingw-w64-crt/stdio/_scprintf.c b/mingw-w64-crt/stdio/_scprintf.c index bcee08a957b7..42f2e5f231a4 100644 --- a/mingw-w64-crt/stdio/_scprintf.c +++ b/mingw-w64-crt/stdio/_scprintf.c @@ -22,17 +22,8 @@ static int __cdecl emu_scprintf(const char * __restrict__ format, ...) #ifndef __LIBMSVCRT_OS__ -int (__cdecl *__MINGW_IMP_SYMBOL(_scprintf))(const char * __restrict__, ...) = emu_scprintf; - -/* gcc does not provide an easy way to call another variadic function with reusing current arguments - * this source file is used only on i386, so do this function redirect via inline i386 assembly */ -#define ASM_SYM(sym) __MINGW64_STRINGIFY(__MINGW_USYMBOL(sym)) -asm ( -".globl\t" ASM_SYM(_scprintf) "\n\t" -".def\t" ASM_SYM(_scprintf) ";\t.scl\t2;\t.type\t32;\t.endef\n" -ASM_SYM(_scprintf) ":\n\t" - "jmp\t*" ASM_SYM(__MINGW_IMP_SYMBOL(_scprintf)) -); +int __attribute__ ((alias ("emu_scprintf"))) __cdecl _scprintf (const char * __restrict__, ...); +int (__cdecl *__MINGW_IMP_SYMBOL(_scprintf))(const char * __restrict__, ...) = _scprintf; #else diff --git a/mingw-w64-crt/stdio/_vscprintf.c b/mingw-w64-crt/stdio/_vscprintf.c index bb596b4d67dc..cc1147393e78 100644 --- a/mingw-w64-crt/stdio/_vscprintf.c +++ b/mingw-w64-crt/stdio/_vscprintf.c @@ -54,7 +54,8 @@ static int __cdecl emu_vscprintf(const char * __restrict__ format, va_list argli #ifndef __LIBMSVCRT_OS__ -int (__cdecl *__MINGW_IMP_SYMBOL(_vscprintf))(const char * __restrict__, va_list) = emu_vscprintf; +int __attribute__ ((alias ("emu_vscprintf"))) __cdecl _vscprintf (const char * __restrict__, va_list); +int (__cdecl *__MINGW_IMP_SYMBOL(_vscprintf))(const char * __restrict__, va_list) = _vscprintf; #else @@ -78,9 +79,9 @@ static int __cdecl init_vscprintf(const char * __restrict__ format, va_list argl return (__MINGW_IMP_SYMBOL(_vscprintf) = func)(format, arglist); } -#endif - int __cdecl _vscprintf(const char * __restrict__ format, va_list arglist) { return __MINGW_IMP_SYMBOL(_vscprintf)(format, arglist); } + +#endif -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public