|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v4 1/6] tools: add a userspace tools bug.h
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 only purpose of
includeing bug.h. This simplifies that.
v4: address ./scripts/checkpatch.pl --codespell complaints
Signed-off-by: Luis R. Rodriguez <mcgrof@xxxxxxxxxx>
---
tools/include/asm-generic/bug.h | 26 ++++++++++++++++++++++++++
tools/include/linux/bug.h | 6 ++++++
tools/include/linux/kernel.h | 2 ++
3 files changed, 34 insertions(+)
create mode 100644 tools/include/asm-generic/bug.h
create mode 100644 tools/include/linux/bug.h
diff --git a/tools/include/asm-generic/bug.h b/tools/include/asm-generic/bug.h
new file mode 100644
index 000000000000..6c9889e2b764
--- /dev/null
+++ b/tools/include/asm-generic/bug.h
@@ -0,0 +1,26 @@
+#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 */
diff --git a/tools/include/linux/bug.h b/tools/include/linux/bug.h
new file mode 100644
index 000000000000..9be515b40b5c
--- /dev/null
+++ b/tools/include/linux/bug.h
@@ -0,0 +1,6 @@
+#ifndef _TOOLS_LINUX_BUG_H
+#define _TOOLS_LINUX_BUG_H
+
+#include <asm-generic/bug.h>
+
+#endif /* _TOOLS_LINUX_BUG_H */
diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h
index 28607db02bd3..3d385a6d4fc1 100644
--- a/tools/include/linux/kernel.h
+++ b/tools/include/linux/kernel.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)
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |