From 02dfc8d775f0709ab494d4b2cce12c8429ff7530 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Thu, 9 Jan 2014 23:00:54 +0900 Subject: tools include: Move perf's bug.h to a generic place So that it can be shared with others like libtraceevent. Signed-off-by: Namhyung Kim Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Jiri Olsa Cc: Namhyung Kim Cc: Steven Rostedt Link: http://lkml.kernel.org/r/1389276059-8829-4-git-send-email-namhyung@kernel.org [ Added the new header to tools/perf/MANIFEST ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/asm/bug.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tools/include/asm/bug.h (limited to 'tools/include/asm/bug.h') diff --git a/tools/include/asm/bug.h b/tools/include/asm/bug.h new file mode 100644 index 000000000000..eca78df7b8f2 --- /dev/null +++ b/tools/include/asm/bug.h @@ -0,0 +1,23 @@ +#ifndef _TOOLS_ASM_BUG_H +#define _TOOLS_ASM_BUG_H + +#define __WARN_printf(arg...) do { fprintf(stderr, arg); } while (0) + +#define WARN(condition, format...) ({ \ + int __ret_warn_on = !!(condition); \ + if (unlikely(__ret_warn_on)) \ + __WARN_printf(format); \ + unlikely(__ret_warn_on); \ +}) + +#define WARN_ONCE(condition, format...) ({ \ + static int __warned; \ + int __ret_warn_once = !!(condition); \ + \ + if (unlikely(__ret_warn_once)) \ + if (WARN(!__warned, format)) \ + __warned = 1; \ + unlikely(__ret_warn_once); \ +}) + +#endif /* _TOOLS_ASM_BUG_H */ -- cgit v1.2.3 From 741a0c59032faeddac80a6237f3d7846231a3740 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Thu, 9 Jan 2014 23:00:55 +0900 Subject: tools include: Include from asm/bug.h Since it uses unlikely() macro inside WARN() Signed-off-by: Namhyung Kim Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Jiri Olsa Cc: Namhyung Kim Cc: Steven Rostedt Link: http://lkml.kernel.org/r/1389276059-8829-5-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/asm/bug.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tools/include/asm/bug.h') diff --git a/tools/include/asm/bug.h b/tools/include/asm/bug.h index eca78df7b8f2..9e5f4846967f 100644 --- a/tools/include/asm/bug.h +++ b/tools/include/asm/bug.h @@ -1,6 +1,8 @@ #ifndef _TOOLS_ASM_BUG_H #define _TOOLS_ASM_BUG_H +#include + #define __WARN_printf(arg...) do { fprintf(stderr, arg); } while (0) #define WARN(condition, format...) ({ \ -- cgit v1.2.3