bug.h 1.2 KB

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