Mesa (master): util: Add debug_printf_once

Jakob Bornecrantz wallbraker at kemper.freedesktop.org
Mon Apr 27 12:25:08 UTC 2009


Module: Mesa
Branch: master
Commit: b618827fac84ca12a354da5808f30e96bedbc92a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b618827fac84ca12a354da5808f30e96bedbc92a

Author: Micah Dowty <micah at vmware.com>
Date:   Fri Apr 24 23:45:16 2009 +0200

util: Add debug_printf_once

---

 src/gallium/auxiliary/util/u_debug.h |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index bcd8f0f..d42b65c 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




More information about the mesa-commit mailing list