]> git.sesse.net Git - bcachefs-tools-debian/blob - include/linux/bug.h
bcache in userspace; userspace fsck
[bcachefs-tools-debian] / include / linux / bug.h
1 #ifndef __TOOLS_LINUX_BUG_H
2 #define __TOOLS_LINUX_BUG_H
3
4 #include <assert.h>
5 #include <linux/compiler.h>
6
7 #define BUILD_BUG_ON_NOT_POWER_OF_2(n)                  \
8         BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
9 #define BUILD_BUG_ON_ZERO(e)    (sizeof(struct { int:-!!(e); }))
10 #define BUILD_BUG_ON_NULL(e)    ((void *)sizeof(struct { int:-!!(e); }))
11
12 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
13
14 #define BUG()                   do { assert(0); unreachable(); } while (0)
15 #define BUG_ON(cond)            assert(!(cond))
16
17 #define WARN_ON_ONCE(cond)      assert(!(cond))
18 #define WARN_ONCE(cond, msg)    assert(!(cond))
19
20 #define __WARN()                assert(0)
21 #define __WARN_printf(arg...)   assert(0)
22 #define WARN(cond, ...)         assert(!(cond))
23
24 #define WARN_ON(condition) ({                                           \
25         int __ret_warn_on = !!(condition);                              \
26         if (unlikely(__ret_warn_on))                                    \
27                 __WARN();                                               \
28         unlikely(__ret_warn_on);                                        \
29 })
30
31 #endif /* __TOOLS_LINUX_BUG_H */