at v2.6.19-rc1 60 lines 1.3 kB view raw
1#ifndef _ASM_GENERIC_BUG_H 2#define _ASM_GENERIC_BUG_H 3 4#include <linux/compiler.h> 5 6#ifdef CONFIG_BUG 7#ifndef HAVE_ARCH_BUG 8#define BUG() do { \ 9 printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ 10 panic("BUG!"); \ 11} while (0) 12#endif 13 14#ifndef HAVE_ARCH_BUG_ON 15#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) 16#endif 17 18#ifndef HAVE_ARCH_WARN_ON 19#define WARN_ON(condition) ({ \ 20 typeof(condition) __ret_warn_on = (condition); \ 21 if (unlikely(__ret_warn_on)) { \ 22 printk("BUG: warning at %s:%d/%s()\n", __FILE__, \ 23 __LINE__, __FUNCTION__); \ 24 dump_stack(); \ 25 } \ 26 unlikely(__ret_warn_on); \ 27}) 28#endif 29 30#else /* !CONFIG_BUG */ 31#ifndef HAVE_ARCH_BUG 32#define BUG() 33#endif 34 35#ifndef HAVE_ARCH_BUG_ON 36#define BUG_ON(condition) do { if (condition) ; } while(0) 37#endif 38 39#ifndef HAVE_ARCH_WARN_ON 40#define WARN_ON(condition) unlikely((condition)) 41#endif 42#endif 43 44#define WARN_ON_ONCE(condition) ({ \ 45 static int __warn_once = 1; \ 46 typeof(condition) __ret_warn_once = (condition);\ 47 \ 48 if (likely(__warn_once)) \ 49 if (WARN_ON(__ret_warn_once)) \ 50 __warn_once = 0; \ 51 unlikely(__ret_warn_once); \ 52}) 53 54#ifdef CONFIG_SMP 55# define WARN_ON_SMP(x) WARN_ON(x) 56#else 57# define WARN_ON_SMP(x) do { } while (0) 58#endif 59 60#endif