diff mbox

[v4,1/6] tools: add a userspace tools bug.h

Message ID 20170115211215.17216-2-mcgrof@kernel.org (mailing list archive)
State New, archived
Headers show

Commit Message

Luis R. Rodriguez Jan. 15, 2017, 9:12 p.m. UTC
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@kernel.org>
---
 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

Comments

Greg KH Jan. 19, 2017, 11:01 a.m. UTC | #1
On Sun, Jan 15, 2017 at 01:12:10PM -0800, Luis R. Rodriguez wrote:
> This will be used later by the userspace linker-tables sandbox.

What is that?

> 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.

I can't parse this sentance at all, please simplify or clarify or
something so that I understand what is going on here.

> This simplifies that.

What is "that"?  You can't do that for such a complex previous sentence.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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)