From: Max TenEyck Woodbury Subject: [Resend] Add '_ONCE' variants of DPRINTF, FIXME, WARN. Message-Id: <1279344565-3397-1-git-send-email-max@mtew.isa-geek.net> Date: Sat, 17 Jul 2010 01:29:25 -0400 --- include/wine/debug.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-) diff --git a/include/wine/debug.h b/include/wine/debug.h index ba6fabe..378a4de 100644 --- a/include/wine/debug.h +++ b/include/wine/debug.h @@ -87,6 +87,14 @@ struct __wine_debug_channel const enum __wine_debug_class __dbcl = __WINE_DBCL##dbcl; \ __WINE_DBG_LOG +#define __WINE_DPRINTF_ONCE(dbcl,dbch) \ + do { static volatile unsigned char once = 0U; \ + if(once == 0U && __WINE_GET_DEBUGGING(dbcl,(dbch)) ) { \ + struct __wine_debug_channel * const __dbch = (dbch); \ + const enum __wine_debug_class __dbcl = __WINE_DBCL##dbcl; \ + once = ~(unsigned char)0U; \ + __WINE_DBG_LOG + #define __WINE_DBG_LOG(args...) \ wine_dbg_log( __dbcl, __dbch, __FUNCTION__, args); } } while(0) @@ -101,8 +109,12 @@ struct __wine_debug_channel #ifdef WINE_NO_DEBUG_MSGS #define WINE_WARN(args...) do { } while(0) #define WINE_WARN_(ch) WINE_WARN +#define WINE_WARN_ONCE(args...) do { } while(0) +#define WINE_WARN_ONCE_(ch) WINE_WARN_ONCE #define WINE_FIXME(args...) do { } while(0) #define WINE_FIXME_(ch) WINE_FIXME +#define WINE_FIXME_ONCE(args...) do { } while(0) +#define WINE_FIXME_ONCE_ONCE_(ch) WINE_FIXME_ONCE #endif #elif defined(__SUNPRO_C) @@ -113,6 +125,14 @@ struct __wine_debug_channel const enum __WINE_DEBUG_CLASS __dbcl = __WINE_DBCL##dbcl; \ __WINE_DBG_LOG +#define __WINE_DPRINTF_ONCE(dbcl,dbch) \ + do { static volatile unsigned char once = 0U; \ + if(__WINE_GET_DEBUGGING(dbcl,(dbch))) { \ + struct __wine_debug_channel * const __dbch = (dbch); \ + const enum __WINE_DEBUG_CLASS __dbcl = __WINE_DBCL##dbcl; \ + once = ~(unsigned char)0U; \ + __WINE_DBG_LOG + #define __WINE_DBG_LOG(...) \ wine_dbg_log( __dbcl, __dbch, __func__, __VA_ARGS__); } } while(0) @@ -126,8 +146,12 @@ struct __wine_debug_channel #ifdef WINE_NO_DEBUG_MSGS #define WINE_WARN(...) do { } while(0) #define WINE_WARN_(ch) WINE_WARN +#define WINE_WARN_ONCE(args...) do { } while(0) +#define WINE_WARN_ONCE_(ch) WINE_WARN_ONCE #define WINE_FIXME(...) do { } while(0) #define WINE_FIXME_(ch) WINE_FIXME +#define WINE_FIXME_ONCE(args...) do { } while(0) +#define WINE_FIXME_ONCE_ONCE_(ch) WINE_FIXME_ONCE #endif #else /* !__GNUC__ && !__SUNPRO_C */ @@ -137,6 +161,11 @@ struct __wine_debug_channel (wine_dbg_log(__WINE_DBCL##dbcl,(dbch),__FILE__,"%d: ",__LINE__) == -1)) ? \ (void)0 : (void)wine_dbg_printf +#define __WINE_DPRINTF_ONCE(dbcl,dbch) /* FIXME */ \ + (!__WINE_GET_DEBUGGING(dbcl,(dbch)) || \ + (wine_dbg_log(__WINE_DBCL##dbcl,(dbch),__FILE__,"%d: ",__LINE__) == -1)) ? \ + (void)0 : (void)wine_dbg_printf + #define __WINE_PRINTF_ATTR(fmt, args) #endif /* !__GNUC__ && !__SUNPRO_C */ @@ -229,17 +258,27 @@ static inline const char *wine_dbgstr_longlong( ULONGLONG ll ) #define WINE_WARN __WINE_DPRINTF(_WARN,__wine_dbch___default) #define WINE_WARN_(ch) __WINE_DPRINTF(_WARN,&__wine_dbch_##ch) #endif +#ifndef WINE_WARN_ONCE +#define WINE_WARN_ONCE __WINE_DPRINTF_ONCE(_WARN,__wine_dbch___default) +#define WINE_WARN_ONCE_(ch) __WINE_DPRINTF_ONCE(_WARN,&__wine_dbch_##ch) +#endif #define WINE_WARN_ON(ch) __WINE_IS_DEBUG_ON(_WARN,&__wine_dbch_##ch) #ifndef WINE_FIXME #define WINE_FIXME __WINE_DPRINTF(_FIXME,__wine_dbch___default) #define WINE_FIXME_(ch) __WINE_DPRINTF(_FIXME,&__wine_dbch_##ch) #endif +#ifndef WINE_FIXME_ONCE +#define WINE_FIXME_ONCE __WINE_DPRINTF_ONCE(_FIXME,__wine_dbch___default) +#define WINE_FIXME_ONCE_(ch) __WINE_DPRINTF_ONCE(_FIXME,__wine_dbch_##ch) +#endif #define WINE_FIXME_ON(ch) __WINE_IS_DEBUG_ON(_FIXME,&__wine_dbch_##ch) #define WINE_ERR __WINE_DPRINTF(_ERR,__wine_dbch___default) #define WINE_ERR_(ch) __WINE_DPRINTF(_ERR,&__wine_dbch_##ch) #define WINE_ERR_ON(ch) __WINE_IS_DEBUG_ON(_ERR,&__wine_dbch_##ch) +#define WINE_ERR_ONCE __WINE_DPRINTF_ONCE(_ERR,__wine_dbch___default) +#define WINE_ERR_ONCE_(ch) __WINE_DPRINTF_ONCE(_ERR,&__wine_dbch_##ch) #define WINE_DECLARE_DEBUG_CHANNEL(ch) \ static struct __wine_debug_channel __wine_dbch_##ch = { ~0, #ch } @@ -266,15 +305,21 @@ static inline const char *debugstr_w( const WCHAR *s ) { return wine_dbgstr_wn( #define WARN WINE_WARN #define WARN_(ch) WINE_WARN_(ch) #define WARN_ON(ch) WINE_WARN_ON(ch) +#define WARN_ONCE WINE_WARN_ONCE +#define WARN_ONCE_(ch) WINE_WARE_ONCE_(ch) #define FIXME WINE_FIXME #define FIXME_(ch) WINE_FIXME_(ch) #define FIXME_ON(ch) WINE_FIXME_ON(ch) +#define FIXME_ONCE WINE_FIXME_ONCE +#define FIXME_ONCE_(ch) WINE_FIXME_ONCE_(ch) #undef ERR /* Solaris got an 'ERR' define in */ #define ERR WINE_ERR #define ERR_(ch) WINE_ERR_(ch) #define ERR_ON(ch) WINE_ERR_ON(ch) +#define ERR_ONCE WINE_ERR_ONCEE +#define ERR_ONCE_(ch) WINE_ERR_ONCE_(ch) #define DPRINTF WINE_DPRINTF #define MESSAGE WINE_MESSAGE -- 1.7.1.1