xref: /OK3568_Linux_fs/kernel/arch/mips/include/asm/bug.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef __ASM_BUG_H
3*4882a593Smuzhiyun #define __ASM_BUG_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/compiler.h>
6*4882a593Smuzhiyun #include <asm/sgidefs.h>
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #ifdef CONFIG_BUG
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #include <asm/break.h>
11*4882a593Smuzhiyun 
BUG(void)12*4882a593Smuzhiyun static inline void __noreturn BUG(void)
13*4882a593Smuzhiyun {
14*4882a593Smuzhiyun 	__asm__ __volatile__("break %0" : : "i" (BRK_BUG));
15*4882a593Smuzhiyun 	unreachable();
16*4882a593Smuzhiyun }
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun #define HAVE_ARCH_BUG
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun #if (_MIPS_ISA > _MIPS_ISA_MIPS1)
21*4882a593Smuzhiyun 
__BUG_ON(unsigned long condition)22*4882a593Smuzhiyun static inline void  __BUG_ON(unsigned long condition)
23*4882a593Smuzhiyun {
24*4882a593Smuzhiyun 	if (__builtin_constant_p(condition)) {
25*4882a593Smuzhiyun 		if (condition)
26*4882a593Smuzhiyun 			BUG();
27*4882a593Smuzhiyun 		else
28*4882a593Smuzhiyun 			return;
29*4882a593Smuzhiyun 	}
30*4882a593Smuzhiyun 	__asm__ __volatile__("tne $0, %0, %1"
31*4882a593Smuzhiyun 			     : : "r" (condition), "i" (BRK_BUG));
32*4882a593Smuzhiyun }
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun #define BUG_ON(C) __BUG_ON((unsigned long)(C))
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun #define HAVE_ARCH_BUG_ON
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun #endif /* _MIPS_ISA > _MIPS_ISA_MIPS1 */
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun #endif
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun #include <asm-generic/bug.h>
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun #endif /* __ASM_BUG_H */
45