Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/parisc/include/asm/bug.h
49174 views
1
/* SPDX-License-Identifier: GPL-2.0 */
2
#ifndef _PARISC_BUG_H
3
#define _PARISC_BUG_H
4
5
/*
6
* Tell the user there is some problem.
7
* The offending file and line are encoded in the __bug_table section.
8
*/
9
10
#ifdef CONFIG_BUG
11
#define HAVE_ARCH_BUG
12
#define HAVE_ARCH_WARN_ON
13
14
/* the break instruction is used as BUG() marker. */
15
#define PARISC_BUG_BREAK_ASM "break 0x1f, 0x1fff"
16
#define PARISC_BUG_BREAK_INSN 0x03ffe01f /* PARISC_BUG_BREAK_ASM */
17
18
#ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
19
# define __BUG_REL(val) ".word " __stringify(val) " - ."
20
#else
21
# define __BUG_REL(val) ".word " __stringify(val)
22
#endif
23
24
25
#ifdef CONFIG_DEBUG_BUGVERBOSE
26
#define BUG() \
27
do { \
28
asm volatile("\n" \
29
"1:\t" PARISC_BUG_BREAK_ASM "\n" \
30
"\t.pushsection __bug_table,\"a\"\n" \
31
"\t.align 4\n" \
32
"2:\t" __BUG_REL(1b) "\n" \
33
"\t" __BUG_REL(%c0) "\n" \
34
"\t.short %1, %2\n" \
35
"\t.blockz %3-2*4-2*2\n" \
36
"\t.popsection" \
37
: : "i" (__FILE__), "i" (__LINE__), \
38
"i" (0), "i" (sizeof(struct bug_entry)) ); \
39
unreachable(); \
40
} while(0)
41
42
#else
43
#define BUG() \
44
do { \
45
asm volatile(PARISC_BUG_BREAK_ASM : : ); \
46
unreachable(); \
47
} while(0)
48
#endif
49
50
#ifdef CONFIG_DEBUG_BUGVERBOSE
51
#define __WARN_FLAGS(cond_str, flags) \
52
do { \
53
asm volatile("\n" \
54
"1:\t" PARISC_BUG_BREAK_ASM "\n" \
55
"\t.pushsection __bug_table,\"a\"\n" \
56
"\t.align 4\n" \
57
"2:\t" __BUG_REL(1b) "\n" \
58
"\t" __BUG_REL(%c0) "\n" \
59
"\t.short %1, %2\n" \
60
"\t.blockz %3-2*4-2*2\n" \
61
"\t.popsection" \
62
: : "i" (WARN_CONDITION_STR(cond_str) __FILE__), "i" (__LINE__), \
63
"i" (BUGFLAG_WARNING|(flags)), \
64
"i" (sizeof(struct bug_entry)) ); \
65
} while(0)
66
#else
67
#define __WARN_FLAGS(cond_str, flags) \
68
do { \
69
asm volatile("\n" \
70
"1:\t" PARISC_BUG_BREAK_ASM "\n" \
71
"\t.pushsection __bug_table,\"a\"\n" \
72
"\t.align 4\n" \
73
"2:\t" __BUG_REL(1b) "\n" \
74
"\t.short %0\n" \
75
"\t.blockz %1-4-2\n" \
76
"\t.popsection" \
77
: : "i" (BUGFLAG_WARNING|(flags)), \
78
"i" (sizeof(struct bug_entry)) ); \
79
} while(0)
80
#endif
81
82
83
#define WARN_ON(x) ({ \
84
int __ret_warn_on = !!(x); \
85
if (__builtin_constant_p(__ret_warn_on)) { \
86
if (__ret_warn_on) \
87
__WARN(); \
88
} else { \
89
if (unlikely(__ret_warn_on)) \
90
__WARN(); \
91
} \
92
unlikely(__ret_warn_on); \
93
})
94
95
#endif
96
97
#include <asm-generic/bug.h>
98
#endif
99
100
101