Mesa (master): intel: Add a macro for printing a debug warning once.

Eric Anholt anholt at kemper.freedesktop.org
Tue Oct 16 20:23:52 UTC 2012


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

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Oct 12 12:41:56 2012 -0700

intel: Add a macro for printing a debug warning once.

There are a number of places where some obscure piece of the code is not
currently worth fixing, and we have some workaround behavior available.  It's
nicer for users to do some lame workaround than to just assert, but without
asserts we never knew when the workaround was at fault.

This should give us a nice compromise: Execute the workaround, but mention
that the obscure workaround was hit.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/drivers/dri/intel/intel_context.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
index b732696..eeefadf 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -483,6 +483,17 @@ extern int INTEL_DEBUG;
 		dbg_printf(__VA_ARGS__);			\
 } while(0)
 
+#define WARN_ONCE(cond, fmt...) do {                            \
+   if (unlikely(cond)) {                                        \
+      static bool _warned = false;                              \
+      if (!_warned) {                                           \
+         fprintf(stderr, "WARNING: ");                          \
+         fprintf(stderr, fmt);                                  \
+         _warned = true;                                        \
+      }                                                         \
+   }                                                            \
+} while (0)
+
 #define PCI_CHIP_845_G			0x2562
 #define PCI_CHIP_I830_M			0x3577
 #define PCI_CHIP_I855_GM		0x3582




More information about the mesa-commit mailing list