1 #ifndef _ASM_GENERIC_BUG_H 2 #define _ASM_GENERIC_BUG_H 3 4 #include <linux/compiler.h> 5 6 #ifdef CONFIG_BUG 7 8 #ifdef CONFIG_GENERIC_BUG 9 #ifndef __ASSEMBLY__ 10 struct bug_entry { 11 unsigned long bug_addr; 12 #ifdef CONFIG_DEBUG_BUGVERBOSE 13 const char *file; 14 unsigned short line; 15 #endif 16 unsigned short flags; 17 }; 18 #endif /* __ASSEMBLY__ */ 19 20 #define BUGFLAG_WARNING (1<<0) 21 #endif /* CONFIG_GENERIC_BUG */ 22 23 #ifndef HAVE_ARCH_BUG 24 #define BUG() do { \ 25 printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ 26 panic("BUG!"); \ 27 } while (0) 28 #endif 29 30 #ifndef HAVE_ARCH_BUG_ON 31 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0) 32 #endif 33 34 #ifndef __WARN 35 #ifndef __ASSEMBLY__ 36 extern void warn_on_slowpath(const char *file, const int line); 37 #define WANT_WARN_ON_SLOWPATH 38 #endif 39 #define __WARN() warn_on_slowpath(__FILE__, __LINE__) 40 #endif 41 42 #ifndef WARN_ON 43 #define WARN_ON(condition) ({ \ 44 int __ret_warn_on = !!(condition); \ 45 if (unlikely(__ret_warn_on)) \ 46 __WARN(); \ 47 unlikely(__ret_warn_on); \ 48 }) 49 #endif 50 51 #else /* !CONFIG_BUG */ 52 #ifndef HAVE_ARCH_BUG 53 #define BUG() 54 #endif 55 56 #ifndef HAVE_ARCH_BUG_ON 57 #define BUG_ON(condition) do { if (condition) ; } while(0) 58 #endif 59 60 #ifndef HAVE_ARCH_WARN_ON 61 #define WARN_ON(condition) ({ \ 62 int __ret_warn_on = !!(condition); \ 63 unlikely(__ret_warn_on); \ 64 }) 65 #endif 66 #endif 67 68 #define WARN_ON_ONCE(condition) ({ \ 69 static int __warned; \ 70 int __ret_warn_once = !!(condition); \ 71 \ 72 if (unlikely(__ret_warn_once)) \ 73 if (WARN_ON(!__warned)) \ 74 __warned = 1; \ 75 unlikely(__ret_warn_once); \ 76 }) 77 78 #ifdef CONFIG_SMP 79 # define WARN_ON_SMP(x) WARN_ON(x) 80 #else 81 # define WARN_ON_SMP(x) do { } while (0) 82 #endif 83 84 #endif 85