disable sstrip when using musl
[lede.git] / target / linux / ubicom32 / files / arch / ubicom32 / include / asm / bug.h
1 /*
2  * arch/ubicom32/include/asm/bug.h
3  *   Generic bug.h for Ubicom32 architecture.
4  *
5  * (C) Copyright 2009, Ubicom, Inc.
6  *
7  * This file is part of the Ubicom32 Linux Kernel Port.
8  *
9  * The Ubicom32 Linux Kernel Port is free software: you can redistribute
10  * it and/or modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation, either version 2 of the
12  * License, or (at your option) any later version.
13  *
14  * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
17  * the GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with the Ubicom32 Linux Kernel Port.  If not,
21  * see <http://www.gnu.org/licenses/>.
22  *
23  * Ubicom32 implementation derived from (with many thanks):
24  *   arch/m68knommu
25  *   arch/blackfin
26  *   arch/parisc
27  */
28 #ifndef _ASM_UBICOM32_BUG_H
29 #define _ASM_UBICOM32_BUG_H
30
31 #include <linux/kernel.h>
32 #include <asm/thread.h>
33
34 #if defined(CONFIG_BUG) && defined(CONFIG_STOP_ON_BUG)
35
36 /*
37  * BUG()
38  *      Ubicom specific version of the BUG() macro.
39  *
40  * This implementation performs a THREAD_STALL stopping all threads before
41  * calling panic.  This enables a developer to see the "real" state of the
42  * machine (since panic alters the system state).  We do the printf first
43  * because while it is slow, it does not alter system state (like
44  * interrupts).
45  *
46  * TODO: Implement the trap sequence used by other architectures.
47  */
48 #define BUG() do { \
49         printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
50         THREAD_STALL; \
51         panic("BUG!"); \
52 } while (0)
53
54
55 /*
56  * __WARN()
57  *      WARN() using printk() for now.
58  *
59  * TODO: Implement the trap sequence used by other architectures.
60  */
61 #define __WARN()                                                        \
62         do {                                                            \
63                 printk("WARN: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
64         } while(0)
65
66 /*
67  * WARN_ON()
68  *      Ubicom specific version of the WARN_ON macro.
69  *
70  * This implementation performs a printk for the WARN_ON() instead
71  * of faulting into the kernel and using report_bug().
72  *
73  * TODO: Implement the trap sequence used by other architectures.
74  */
75 #define WARN_ON(x) ({                                           \
76         int __ret_warn_on = !!(x);                              \
77         if (__builtin_constant_p(__ret_warn_on)) {              \
78                 if (__ret_warn_on)                              \
79                         __WARN();                               \
80         } else {                                                \
81                 if (unlikely(__ret_warn_on))                    \
82                         __WARN();                               \
83         }                                                       \
84         unlikely(__ret_warn_on);                                \
85 })
86
87
88 #define HAVE_ARCH_BUG
89 #define HAVE_ARCH_WARN_ON
90
91 #endif
92
93 #include <asm-generic/bug.h>
94
95 #endif /* _ASM_UBICOM32_BUG_H */