xref: /openbmc/linux/tools/include/asm/bug.h (revision 02dfc8d7)
102dfc8d7SNamhyung Kim #ifndef _TOOLS_ASM_BUG_H
202dfc8d7SNamhyung Kim #define _TOOLS_ASM_BUG_H
302dfc8d7SNamhyung Kim 
402dfc8d7SNamhyung Kim #define __WARN_printf(arg...)	do { fprintf(stderr, arg); } while (0)
502dfc8d7SNamhyung Kim 
602dfc8d7SNamhyung Kim #define WARN(condition, format...) ({		\
702dfc8d7SNamhyung Kim 	int __ret_warn_on = !!(condition);	\
802dfc8d7SNamhyung Kim 	if (unlikely(__ret_warn_on))		\
902dfc8d7SNamhyung Kim 		__WARN_printf(format);		\
1002dfc8d7SNamhyung Kim 	unlikely(__ret_warn_on);		\
1102dfc8d7SNamhyung Kim })
1202dfc8d7SNamhyung Kim 
1302dfc8d7SNamhyung Kim #define WARN_ONCE(condition, format...)	({	\
1402dfc8d7SNamhyung Kim 	static int __warned;			\
1502dfc8d7SNamhyung Kim 	int __ret_warn_once = !!(condition);	\
1602dfc8d7SNamhyung Kim 						\
1702dfc8d7SNamhyung Kim 	if (unlikely(__ret_warn_once))		\
1802dfc8d7SNamhyung Kim 		if (WARN(!__warned, format)) 	\
1902dfc8d7SNamhyung Kim 			__warned = 1;		\
2002dfc8d7SNamhyung Kim 	unlikely(__ret_warn_once);		\
2102dfc8d7SNamhyung Kim })
2202dfc8d7SNamhyung Kim 
2302dfc8d7SNamhyung Kim #endif /* _TOOLS_ASM_BUG_H */
24