bug.h 1.6 KB
Newer Older
H
Heiko Carstens 已提交
1 2
#ifndef _ASM_S390_BUG_H
#define _ASM_S390_BUG_H
L
Linus Torvalds 已提交
3 4 5

#include <linux/kernel.h>

M
Matt Mackall 已提交
6
#ifdef CONFIG_BUG
7

H
Heiko Carstens 已提交
8 9
#ifdef CONFIG_64BIT
#define S390_LONG ".quad"
10
#else
H
Heiko Carstens 已提交
11
#define S390_LONG ".long"
12 13
#endif

H
Heiko Carstens 已提交
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#ifdef CONFIG_DEBUG_BUGVERBOSE

#define __EMIT_BUG(x) do {					\
	asm volatile(						\
		"0:	j	0b+2\n"				\
		"1:\n"						\
		".section .rodata.str,\"aMS\",@progbits,1\n"	\
		"2:	.asciz	\""__FILE__"\"\n"		\
		".previous\n"					\
		".section __bug_table,\"a\"\n"			\
		"3:\t"	S390_LONG "\t1b,2b\n"			\
		"	.short	%0,%1\n"			\
		"	.org	3b+%2\n"			\
		".previous\n"					\
		: : "i" (__LINE__),				\
		    "i" (x),					\
		    "i" (sizeof(struct bug_entry)));		\
L
Linus Torvalds 已提交
31 32
} while (0)

H
Heiko Carstens 已提交
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#else /* CONFIG_DEBUG_BUGVERBOSE */

#define __EMIT_BUG(x) do {				\
	asm volatile(					\
		"0:	j	0b+2\n"			\
		"1:\n"					\
		".section __bug_table,\"a\"\n"		\
		"2:\t"	S390_LONG "\t1b\n"		\
		"	.short	%0\n"			\
		"	.org	2b+%1\n"		\
		".previous\n"				\
		: : "i" (x),				\
		    "i" (sizeof(struct bug_entry)));	\
} while (0)

#endif /* CONFIG_DEBUG_BUGVERBOSE */

50 51
#define BUG() do {					\
	__EMIT_BUG(0);					\
52
	unreachable();					\
53
} while (0)
H
Heiko Carstens 已提交
54

55 56 57 58
#define __WARN() do {					\
	__EMIT_BUG(BUGFLAG_WARNING);			\
} while (0)

H
Heiko Carstens 已提交
59
#define WARN_ON(x) ({					\
60
	int __ret_warn_on = !!(x);			\
H
Heiko Carstens 已提交
61 62 63 64 65 66 67 68 69 70
	if (__builtin_constant_p(__ret_warn_on)) {	\
		if (__ret_warn_on)			\
			__EMIT_BUG(BUGFLAG_WARNING);	\
	} else {					\
		if (unlikely(__ret_warn_on))		\
			__EMIT_BUG(BUGFLAG_WARNING);	\
	}						\
	unlikely(__ret_warn_on);			\
})

L
Linus Torvalds 已提交
71
#define HAVE_ARCH_BUG
H
Heiko Carstens 已提交
72 73
#define HAVE_ARCH_WARN_ON
#endif /* CONFIG_BUG */
M
Matt Mackall 已提交
74

L
Linus Torvalds 已提交
75 76
#include <asm-generic/bug.h>

H
Heiko Carstens 已提交
77
#endif /* _ASM_S390_BUG_H */