summaryrefslogtreecommitdiff
path: root/include/linux/bug.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2017-01-08 00:13:18 -0900
committerKent Overstreet <kent.overstreet@gmail.com>2017-01-20 09:07:08 -0900
commitb33fc8298f7e13226b9895abc57c9bfce5e3fa2d (patch)
treea3d2a5a909b6372f7777c1c5c18cef5f81d123a9 /include/linux/bug.h
parent7f4191a202ea4558ca2d5eb8a47daea33c9999c7 (diff)
bcache in userspace; userspace fsck
Diffstat (limited to 'include/linux/bug.h')
-rw-r--r--include/linux/bug.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/bug.h b/include/linux/bug.h
new file mode 100644
index 0000000..f01e5f7
--- /dev/null
+++ b/include/linux/bug.h
@@ -0,0 +1,31 @@
+#ifndef __TOOLS_LINUX_BUG_H
+#define __TOOLS_LINUX_BUG_H
+
+#include <assert.h>
+#include <linux/compiler.h>
+
+#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \
+ BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
+#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
+#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
+
+#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
+
+#define BUG() do { assert(0); unreachable(); } while (0)
+#define BUG_ON(cond) assert(!(cond))
+
+#define WARN_ON_ONCE(cond) assert(!(cond))
+#define WARN_ONCE(cond, msg) assert(!(cond))
+
+#define __WARN() assert(0)
+#define __WARN_printf(arg...) assert(0)
+#define WARN(cond, ...) assert(!(cond))
+
+#define WARN_ON(condition) ({ \
+ int __ret_warn_on = !!(condition); \
+ if (unlikely(__ret_warn_on)) \
+ __WARN(); \
+ unlikely(__ret_warn_on); \
+})
+
+#endif /* __TOOLS_LINUX_BUG_H */