2017-01-08 12:13:18 +03:00
|
|
|
#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))
|
|
|
|
|
2017-12-22 02:00:30 +03:00
|
|
|
#define WARN_ON_ONCE(cond) ({ bool _r = (cond); if (_r) assert(0); _r; })
|
2018-04-11 02:19:09 +03:00
|
|
|
#define WARN_ONCE(cond, ...) ({ bool _r = (cond); if (_r) assert(0); _r; })
|
2017-01-08 12:13:18 +03:00
|
|
|
|
|
|
|
#define __WARN() assert(0)
|
|
|
|
#define __WARN_printf(arg...) assert(0)
|
|
|
|
#define WARN(cond, ...) assert(!(cond))
|
|
|
|
|
|
|
|
#define WARN_ON(condition) ({ \
|
2017-04-04 11:28:13 +03:00
|
|
|
int __ret_warn_on = unlikely(!!(condition)); \
|
|
|
|
if (__ret_warn_on) \
|
2017-01-08 12:13:18 +03:00
|
|
|
__WARN(); \
|
2017-04-04 11:28:13 +03:00
|
|
|
__ret_warn_on; \
|
2017-01-08 12:13:18 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
#endif /* __TOOLS_LINUX_BUG_H */
|