backport WARN_ON_ONCE macro for 2.6.16

Signed-off-by: Stefan Roscher <[EMAIL PROTECTED]>
---


diff -Nurp a/include/asm-generic/bug.h b/include/asm-generic/bug.h
--- a/include/asm-generic/bug.h 1970-01-01 01:00:00.000000000 +0100
+++ b/include/asm-generic/bug.h 2007-03-08 14:56:10.000000000 +0100
@@ -0,0 +1,34 @@
+#ifndef _BACKPORT_ASM_GENERIC_BUG_H
+#define _BACKPORT_ASM_GENERIC_BUG_H
+
+#include_next <asm-generic/bug.h>
+
+#ifdef CONFIG_BUG
+#define WARN_ON_2(condition) ({                                 \
+        typeof(condition) __ret_warn_on = (condition);          \
+        if (unlikely(__ret_warn_on)) {                          \
+                printk("BUG: at %s:%d %s()\n", __FILE__,        \
+                        __LINE__, __FUNCTION__);                \
+                dump_stack();                                   \
+        }                                                       \
+        unlikely(__ret_warn_on);                                \
+})
+
+#else /* !CONFIG_BUG */
+
+#define WARN_ON_2(condition) ({                                 \
+        typeof(condition) __ret_warn_on = (condition);          \
+        unlikely(__ret_warn_on);                                \
+})
+#endif
+#define WARN_ON_ONCE(condition) ({                              \
+        static int __warned;                                    \
+        typeof(condition) __ret_warn_once = (condition);        \
+                                                                \
+        if (unlikely(__ret_warn_once))                          \
+                if (WARN_ON_2(!__warned))                       \
+                        __warned = 1;                           \
+        unlikely(__ret_warn_once);                              \
+})
+
+#endif




_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to