perf tools: Add WARN_ONCE equivalent for UI warnings
[linux-2.6-microblaze.git] / tools / perf / util / debug.h
index 48f6319..f99468a 100644 (file)
@@ -22,6 +22,13 @@ extern int debug_data_convert;
        eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
 #define pr_warning(fmt, ...) \
        eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warning_once(fmt, ...) ({           \
+       static int __warned;                    \
+       if (unlikely(!__warned)) {              \
+               pr_warning(fmt, ##__VA_ARGS__); \
+               __warned = 1;                   \
+       }                                       \
+})
 #define pr_info(fmt, ...) \
        eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
 #define pr_debug(fmt, ...) \
@@ -55,6 +62,13 @@ void trace_event(union perf_event *event);
 
 int ui__error(const char *format, ...) __printf(1, 2);
 int ui__warning(const char *format, ...) __printf(1, 2);
+#define ui__warning_once(format, ...) ({               \
+       static int __warned;                            \
+       if (unlikely(!__warned)) {                      \
+               ui__warning(format, ##__VA_ARGS__);     \
+               __warned = 1;                           \
+       }                                               \
+})
 
 void pr_stat(const char *fmt, ...);