summaryrefslogtreecommitdiffstats
path: root/include/asm
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 07:25:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 07:25:46 +0000
commit5277429a362a9cf4ce649557bf4c8fe0e20c05c0 (patch)
tree52cc97728c6fbb7393984dc3db05c5836107fe44 /include/asm
parentInitial commit. (diff)
downloadlibtraceevent-upstream.tar.xz
libtraceevent-upstream.zip
Adding upstream version 1:1.7.1.upstream/1%1.7.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'include/asm')
-rw-r--r--include/asm/bug.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/asm/bug.h b/include/asm/bug.h
new file mode 100644
index 0000000..de8f8fe
--- /dev/null
+++ b/include/asm/bug.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _TOOLS_ASM_BUG_H
+#define _TOOLS_ASM_BUG_H
+
+#include <linux/compiler.h>
+#include <stdio.h>
+
+#define __WARN_printf(arg...) do { fprintf(stderr, arg); fprintf(stderr, "\n");} 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_ON(condition) ({ \
+ int __ret_warn_on = !!(condition); \
+ if (unlikely(__ret_warn_on)) \
+ __WARN_printf("assertion failed at %s:%d\n", \
+ __FILE__, __LINE__); \
+ unlikely(__ret_warn_on); \
+})
+
+#define WARN_ON_ONCE(condition) ({ \
+ static int __warned; \
+ int __ret_warn_once = !!(condition); \
+ \
+ if (unlikely(__ret_warn_once && !__warned)) { \
+ __warned = true; \
+ WARN_ON(1); \
+ } \
+ unlikely(__ret_warn_once); \
+})
+
+#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 */