new file mode 100644
@@ -0,0 +1,24 @@
+#ifndef __TOOLS_ASM_GENERIC_BUG
+#define __TOOLS_ASM_GENERIC_BUG
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define BUG() do { \
+ fprintf(stderr, "----------------------------------------------------------\n"); \
+ fprintf (stderr, "BUG on %s at %s: %i\n", __func__, __FILE__, __LINE__); \
+ abort(); \
+} \
+while (0)
+
+#define BUG_ON(cond) do { if (cond) BUG(); } while (0)
+
+#define WARN_ON(__test) do { \
+ if (__test) { \
+ fprintf(stderr, "----------------------------------------------------------\n");\
+ fprintf (stderr, "WARN_ON on %s at %s: %i\n", __func__, __FILE__, __LINE__); \
+ } \
+} \
+while (0)
+
+#endif /* __TOOLS_ASM_GENERIC_BUG */
new file mode 100644
@@ -0,0 +1,6 @@
+#ifndef _TOOLS_LINUX_BUG_H
+#define _TOOLS_LINUX_BUG_H
+
+#include <asm-generic/bug.h>
+
+#endif /* _TOOLS_LINUX_BUG_H */
@@ -5,6 +5,8 @@
#include <stddef.h>
#include <assert.h>
+#include <linux/bug.h>
+
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
#define PERF_ALIGN(x, a) __PERF_ALIGN_MASK(x, (typeof(x))(a)-1)
This will be used later by the userspace linker-tables sandbox. As a convenience, include bug.h on kernel.h -- this is not done on upstream kernel.h, however most header files do include bug.h eventually, if we were to only add the ones that need it we'd need to copy a lot of headers to tools for the ony purpose of includeing bug.h. This simplifies that. Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> --- tools/include/asm-generic/bug.h | 24 ++++++++++++++++++++++++ tools/include/linux/bug.h | 6 ++++++ tools/include/linux/kernel.h | 2 ++ 3 files changed, 32 insertions(+) create mode 100644 tools/include/asm-generic/bug.h create mode 100644 tools/include/linux/bug.h