From: Micah Dowty Date: Fri, 24 Apr 2009 21:45:16 +0000 (+0200) Subject: util: Add debug_printf_once X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b618827fac84ca12a354da5808f30e96bedbc92a;p=mesa.git util: Add debug_printf_once --- diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index bcd8f0f3cf1..d42b65ce281 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -102,6 +102,22 @@ debug_printf(const char *format, ...) } +/* + * ... isn't portable so we need to pass arguments in parentheses. + * + * usage: + * debug_printf_once(("awnser: %i\n", 42)); + */ +#define debug_printf_once(args) \ + do { \ + static boolean once = TRUE; \ + if (once) { \ + once = FALSE; \ + debug_printf args; \ + } \ + } while (0) + + #ifdef DEBUG #define debug_vprintf(_format, _ap) _debug_vprintf(_format, _ap) #else