From 94bf2d48e19b86a4cfa4ff3bf3da97967f8a2793 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 7 Jan 2012 14:16:27 -0700 Subject: [PATCH] util: add debug_warn_once() macro Emits a warning message, but only once to avoid tons of repeated warnings. --- src/gallium/auxiliary/util/u_debug.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index cbea3583037..ed19cda05a2 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -214,6 +214,25 @@ void _debug_assert_fail(const char *expr, #endif +/** + * Emit a warning message, but only once. + */ +#ifdef DEBUG +#define debug_warn_once(__msg) \ + do { \ + static bool warned = FALSE; \ + if (!warned) { \ + _debug_printf("%s:%u:%s: one time warning: %s\n", \ + __FILE__, __LINE__, __FUNCTION__, __msg); \ + warned = TRUE; \ + } \ + } while (0) +#else +#define debug_warn_once(__msg) \ + ((void)0) +#endif + + /** * Output an error message. Not muted on release version. */