blob: bf90d1fd97a59cbd4141f8180be49e7b0cc265f7 [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_DEBUG_BUGVERBOSE
9
10#define __EMIT_BUG(x) do { \
11 asm volatile( \
12 "0: j 0b+2\n" \
13 "1:\n" \
14 ".section .rodata.str,\"aMS\",@progbits,1\n" \
15 "2: .asciz \""__FILE__"\"\n" \
16 ".previous\n" \
17 ".section __bug_table,\"a\"\n" \
Heiko Carstens52499f42010-02-26 22:37:44 +010018 "3: .long 1b-3b,2b-3b\n" \
Heiko Carstensc0007f12007-04-27 16:01:42 +020019 " .short %0,%1\n" \
20 " .org 3b+%2\n" \
21 ".previous\n" \
22 : : "i" (__LINE__), \
23 "i" (x), \
24 "i" (sizeof(struct bug_entry))); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070025} while (0)
26
Heiko Carstensc0007f12007-04-27 16:01:42 +020027#else /* CONFIG_DEBUG_BUGVERBOSE */
28
29#define __EMIT_BUG(x) do { \
30 asm volatile( \
31 "0: j 0b+2\n" \
32 "1:\n" \
33 ".section __bug_table,\"a\"\n" \
Heiko Carstens52499f42010-02-26 22:37:44 +010034 "2: .long 1b-2b\n" \
Heiko Carstensc0007f12007-04-27 16:01:42 +020035 " .short %0\n" \
36 " .org 2b+%1\n" \
37 ".previous\n" \
38 : : "i" (x), \
39 "i" (sizeof(struct bug_entry))); \
40} while (0)
41
42#endif /* CONFIG_DEBUG_BUGVERBOSE */
43
Martin Schwidefsky2d6cd2a2008-12-25 13:39:17 +010044#define BUG() do { \
45 __EMIT_BUG(0); \
David Daney5506e682009-12-04 17:44:53 -080046 unreachable(); \
Martin Schwidefsky2d6cd2a2008-12-25 13:39:17 +010047} while (0)
Heiko Carstensc0007f12007-04-27 16:01:42 +020048
Ben Hutchingsb2be0522010-04-03 19:34:56 +010049#define __WARN_TAINT(taint) do { \
50 __EMIT_BUG(BUGFLAG_TAINT(taint)); \
Heiko Carstensa9df8e32010-01-13 20:44:38 +010051} while (0)
52
Heiko Carstensc0007f12007-04-27 16:01:42 +020053#define WARN_ON(x) ({ \
Heiko Carstensfd0cbdd2007-08-02 00:18:38 +020054 int __ret_warn_on = !!(x); \
Heiko Carstensc0007f12007-04-27 16:01:42 +020055 if (__builtin_constant_p(__ret_warn_on)) { \
56 if (__ret_warn_on) \
Ben Hutchingsb2be0522010-04-03 19:34:56 +010057 __WARN(); \
Heiko Carstensc0007f12007-04-27 16:01:42 +020058 } else { \
59 if (unlikely(__ret_warn_on)) \
Ben Hutchingsb2be0522010-04-03 19:34:56 +010060 __WARN(); \
Heiko Carstensc0007f12007-04-27 16:01:42 +020061 } \
62 unlikely(__ret_warn_on); \
63})
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065#define HAVE_ARCH_BUG
Heiko Carstensc0007f12007-04-27 16:01:42 +020066#define HAVE_ARCH_WARN_ON
67#endif /* CONFIG_BUG */
Matt Mackallc8538a72005-05-01 08:59:01 -070068
Linus Torvalds1da177e2005-04-16 15:20:36 -070069#include <asm-generic/bug.h>
70
Heiko Carstensc0007f12007-04-27 16:01:42 +020071#endif /* _ASM_S390_BUG_H */