From f2e6f05fe33a2933e45c0741847bf0dbbf43b940 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 3 Apr 2019 10:02:14 +0200 Subject: [PATCH] include: Make wine_dbg_sprintf() into an inline function. Signed-off-by: Alexandre Julliard --- include/wine/debug.h | 26 +++++++++++++++++++++++++- libs/wine/debug.c | 2 ++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/wine/debug.h b/include/wine/debug.h index 65322d06f18..fd8e56e67a5 100644 --- a/include/wine/debug.h +++ b/include/wine/debug.h @@ -22,6 +22,7 @@ #define __WINE_WINE_DEBUG_H #include +#include #include #ifndef _NTSYSTEM_ #include @@ -169,12 +170,35 @@ extern const char * __cdecl __wine_dbg_strdup( const char *str ); /* These functions return a printable version of a string, including quotes. The string will be valid for some time, but not indefinitely as strings are re-used. */ -extern const char *wine_dbg_sprintf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2); extern int wine_dbg_printf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2); extern int wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *ch, const char *func, const char *format, ... ) __WINE_PRINTF_ATTR(4,5); +#if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT) +# define __wine_dbg_cdecl __cdecl +# define __wine_dbg_va_list __builtin_ms_va_list +# define __wine_dbg_va_start(list,arg) __builtin_ms_va_start(list,arg) +# define __wine_dbg_va_end(list) __builtin_ms_va_end(list) +#else +# define __wine_dbg_cdecl +# define __wine_dbg_va_list va_list +# define __wine_dbg_va_start(list,arg) va_start(list,arg) +# define __wine_dbg_va_end(list) va_end(list) +#endif + +static const char * __wine_dbg_cdecl wine_dbg_sprintf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2); +static inline const char * __wine_dbg_cdecl wine_dbg_sprintf( const char *format, ... ) +{ + char buffer[200]; + __wine_dbg_va_list args; + + __wine_dbg_va_start( args, format ); + vsnprintf( buffer, sizeof(buffer), format, args ); + __wine_dbg_va_end( args ); + return __wine_dbg_strdup( buffer ); +} + static inline const char *wine_dbgstr_an( const char *str, int n ) { static const char hex[16] = "0123456789abcdef"; diff --git a/libs/wine/debug.c b/libs/wine/debug.c index 0c3b4efafd3..1bf59ddb5ee 100644 --- a/libs/wine/debug.c +++ b/libs/wine/debug.c @@ -30,6 +30,7 @@ # include #endif +#define wine_dbg_sprintf wine_dbg_sprintf_inline #define wine_dbgstr_an wine_dbgstr_an_inline #define wine_dbgstr_wn wine_dbgstr_wn_inline #include "wine/debug.h" @@ -228,6 +229,7 @@ int wine_dbg_printf( const char *format, ... ) } /* printf with temp buffer allocation */ +#undef wine_dbg_sprintf const char *wine_dbg_sprintf( const char *format, ... ) { static const int max_size = 200;