[rfc] WINE_ONCE macro
Dan Kegel
dank at kegel.com
Sat Aug 6 16:12:29 CDT 2011
There are many places in the wine source that use a static
to print a fixme just once. Here's a simple macro that
combines declaring and testing the static.
Thoughts?
diff --git a/include/wine/debug.h b/include/wine/debug.h
index ba6fabe..3112401 100644
--- a/include/wine/debug.h
+++ b/include/wine/debug.h
@@ -250,6 +250,8 @@ static inline const char *wine_dbgstr_longlong(
ULONGLONG ll )
#define WINE_DPRINTF wine_dbg_printf
#define WINE_MESSAGE wine_dbg_printf
+#define WINE_ONCE(s) { static int once; if (!once++) s; }
+
#ifdef __WINESRC__
/* Wine uses shorter names that are very likely to conflict with
other software */
@@ -276,6 +278,8 @@ static inline const char *debugstr_w( const WCHAR
*s ) { return wine_dbgstr_wn(
#define ERR_(ch) WINE_ERR_(ch)
#define ERR_ON(ch) WINE_ERR_ON(ch)
+#define ONCE(s) WINE_ONCE(s)
+
#define DPRINTF WINE_DPRINTF
#define MESSAGE WINE_MESSAGE
And here's an example of its use:
diff --git a/dlls/msvcr90/msvcr90.c b/dlls/msvcr90/msvcr90.c
index fd24f11..af75095 100644
--- a/dlls/msvcr90/msvcr90.c
+++ b/dlls/msvcr90/msvcr90.c
@@ -310,9 +310,7 @@ int CDECL _atoflt( _CRT_FLOAT *value, char *str )
DEFINE_THISCALL_WRAPPER(MSVCRT_type_info_name_internal_method,8)
const char * __thiscall
MSVCRT_type_info_name_internal_method(type_info * _this, struct
__type_info_node *node)
{
- static int once;
-
- if (node && !once++) FIXME("type_info_node parameter ignored\n");
+ if (node) ONCE(FIXME("type_info_node parameter ignored\n"));
if (!_this->name)
{
More information about the wine-devel
mailing list