[PATCH] introduce WARN_ON_ONCE(cond)
authorIngo Molnar <mingo@elte.hu>
Sun, 25 Jun 2006 12:48:09 +0000 (05:48 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 25 Jun 2006 17:01:11 +0000 (10:01 -0700)
Add WARN_ON_ONCE(cond) to print once-per-bootup messages.

[rostedt@goodmis.org: improve code generation]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/asm-generic/bug.h

index 0cd9711895faaf6259baeaf3a66cf6484d41804a..845cb67ad8ea5d40bcb707462d30879255247b81 100644 (file)
 #endif
 #endif
 
+#define WARN_ON_ONCE(condition)                                \
+({                                                     \
+       static int __warn_once = 1;                     \
+       int __ret = 0;                                  \
+                                                       \
+       if (unlikely((condition) && __warn_once)) {     \
+               __warn_once = 0;                        \
+               WARN_ON(1);                             \
+               __ret = 1;                              \
+       }                                               \
+       __ret;                                          \
+})
+
 #endif