You've already forked hardkernel-uboot
mirror of
https://github.com/archr-linux/hardkernel-uboot.git
synced 2026-03-31 15:05:07 -07:00
Collect runtime BUG/WARN into a self-contained header <linux/bug.h> to make these macros easier to use. Change-Id: If924684bdab99d2c8fe0b4b3755d0ee5291d11be Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Kever Yang <kever.yang@rock-chips.com> (cherry picked from commit 0a70fb4c1c180d6ad6cd4c1dcd3fae8c5d4dd62e)
35 lines
869 B
C
35 lines
869 B
C
#ifndef _LINUX_BUG_H
|
|
#define _LINUX_BUG_H
|
|
|
|
#include <vsprintf.h> /* for panic() */
|
|
#include <linux/build_bug.h>
|
|
#include <linux/compiler.h>
|
|
#include <linux/printk.h>
|
|
|
|
#define BUG() do { \
|
|
printk("BUG at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
|
|
panic("BUG!"); \
|
|
} while (0)
|
|
|
|
#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
|
|
|
|
#define WARN_ON(condition) ({ \
|
|
int __ret_warn_on = !!(condition); \
|
|
if (unlikely(__ret_warn_on)) \
|
|
printk("WARNING at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
|
|
unlikely(__ret_warn_on); \
|
|
})
|
|
|
|
#define WARN_ON_ONCE(condition) ({ \
|
|
static bool __warned; \
|
|
int __ret_warn_once = !!(condition); \
|
|
\
|
|
if (unlikely(__ret_warn_once && !__warned)) { \
|
|
__warned = true; \
|
|
WARN_ON(1); \
|
|
} \
|
|
unlikely(__ret_warn_once); \
|
|
})
|
|
|
|
#endif /* _LINUX_BUG_H */
|