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

Author: Pauli Nieminen <suok...@gmail.com>
Date:   Sun Sep 20 20:07:35 2009 +0300

radeon: Improve WARN_ONCE macro to appear as single statement.

Do-while makes macro safe to be used with if and for constructions.

Also remove __LINE__ macro from variable name because scope is local to macro 
anyway.

---

 src/mesa/drivers/dri/radeon/radeon_debug.h |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_debug.h 
b/src/mesa/drivers/dri/radeon/radeon_debug.h
index 2a83022..a591041 100644
--- a/src/mesa/drivers/dri/radeon/radeon_debug.h
+++ b/src/mesa/drivers/dri/radeon/radeon_debug.h
@@ -149,21 +149,22 @@ static inline void radeon_debug_remove_indent(void)
        }
 }
 
+
 /* From http://gcc. gnu.org/onlinedocs/gcc-3.2.3/gcc/Variadic-Macros.html .
    I suppose we could inline this and use macro to fetch out __LINE__ and 
stuff in case we run into trouble
    with other compilers ... GLUE!
 */
-#define WARN_ONCE(a, ...)      { \
-       static int warn##__LINE__=1; \
-       if(warn##__LINE__){ \
+#define WARN_ONCE(a, ...)      do { \
+       static int __warn_once=1; \
+       if(__warn__once){ \
                
radeon_warning("*********************************WARN_ONCE*********************************\n");
 \
                radeon_warning("File %s function %s line %d\n", \
                        __FILE__, __FUNCTION__, __LINE__); \
                radeon_warning(  (a), ## __VA_ARGS__);\
                
radeon_warning("***************************************************************************\n");
 \
-               warn##__LINE__=0;\
+               __warn_once=0;\
                } \
-       }
+       } while(0)
 
 
 #endif

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to