blob: 7efd0abe88871dc494e26adc1ef5b31b7edffcb4 [file] [log] [blame]
Heiko Carstensc0007f12007-04-27 16:01:42 +02001#ifndef _ASM_S390_BUG_H
2#define _ASM_S390_BUG_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
4#include <linux/kernel.h>
5
Matt Mackallc8538a72005-05-01 08:59:01 -07006#ifdef CONFIG_BUG
Martin Schwidefsky4896cef2006-03-24 03:15:16 -08007
Heiko Carstensc0007f12007-04-27 16:01:42 +02008#ifdef CONFIG_64BIT
9#define S390_LONG ".quad"
Heiko Carstensf4a10b22006-07-12 16:39:42 +020010#else
Heiko Carstensc0007f12007-04-27 16:01:42 +020011#define S390_LONG ".long"
Heiko Carstensf4a10b22006-07-12 16:39:42 +020012#endif
Heiko Carstensf4a10b22006-07-12 16:39:42 +020013
Heiko Carstensc0007f12007-04-27 16:01:42 +020014#ifdef CONFIG_DEBUG_BUGVERBOSE
15
16#define __EMIT_BUG(x) do { \
17 asm volatile( \
18 "0: j 0b+2\n" \
19 "1:\n" \
20 ".section .rodata.str,\"aMS\",@progbits,1\n" \
21 "2: .asciz \""__FILE__"\"\n" \
22 ".previous\n" \
23 ".section __bug_table,\"a\"\n" \
24 "3:\t" S390_LONG "\t1b,2b\n" \
25 " .short %0,%1\n" \
26 " .org 3b+%2\n" \
27 ".previous\n" \
28 : : "i" (__LINE__), \
29 "i" (x), \
30 "i" (sizeof(struct bug_entry))); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070031} while (0)
32
Heiko Carstensc0007f12007-04-27 16:01:42 +020033#else /* CONFIG_DEBUG_BUGVERBOSE */
34
35#define __EMIT_BUG(x) do { \
36 asm volatile( \
37 "0: j 0b+2\n" \
38 "1:\n" \
39 ".section __bug_table,\"a\"\n" \
40 "2:\t" S390_LONG "\t1b\n" \
41 " .short %0\n" \
42 " .org 2b+%1\n" \
43 ".previous\n" \
44 : : "i" (x), \
45 "i" (sizeof(struct bug_entry))); \
46} while (0)
47
48#endif /* CONFIG_DEBUG_BUGVERBOSE */
49
Martin Schwidefsky2d6cd2a2008-12-25 13:39:17 +010050#define BUG() do { \
51 __EMIT_BUG(0); \
52 for (;;); \
53} while (0)
Heiko Carstensc0007f12007-04-27 16:01:42 +020054
55#define WARN_ON(x) ({ \
Heiko Carstensfd0cbdd2007-08-02 00:18:38 +020056 int __ret_warn_on = !!(x); \
Heiko Carstensc0007f12007-04-27 16:01:42 +020057 if (__builtin_constant_p(__ret_warn_on)) { \
58 if (__ret_warn_on) \
59 __EMIT_BUG(BUGFLAG_WARNING); \
60 } else { \
61 if (unlikely(__ret_warn_on)) \
62 __EMIT_BUG(BUGFLAG_WARNING); \
63 } \
64 unlikely(__ret_warn_on); \
65})
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#define HAVE_ARCH_BUG
Heiko Carstensc0007f12007-04-27 16:01:42 +020068#define HAVE_ARCH_WARN_ON
69#endif /* CONFIG_BUG */
Matt Mackallc8538a72005-05-01 08:59:01 -070070
Linus Torvalds1da177e2005-04-16 15:20:36 -070071#include <asm-generic/bug.h>
72
Heiko Carstensc0007f12007-04-27 16:01:42 +020073#endif /* _ASM_S390_BUG_H */