bug.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef _ASM_GENERIC_BUG_H
  2. #define _ASM_GENERIC_BUG_H
  3. #include <linux/compiler.h>
  4. #include <linux/config.h>
  5. #ifdef CONFIG_BUG
  6. #ifndef HAVE_ARCH_BUG
  7. #define BUG() do { \
  8. printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
  9. panic("BUG!"); \
  10. } while (0)
  11. #endif
  12. #ifndef HAVE_ARCH_PAGE_BUG
  13. #define PAGE_BUG(page) do { \
  14. printk("page BUG for page at %p\n", page); \
  15. BUG(); \
  16. } while (0)
  17. #endif
  18. #ifndef HAVE_ARCH_BUG_ON
  19. #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
  20. #endif
  21. #ifndef HAVE_ARCH_WARN_ON
  22. #define WARN_ON(condition) do { \
  23. if (unlikely((condition)!=0)) { \
  24. printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
  25. dump_stack(); \
  26. } \
  27. } while (0)
  28. #endif
  29. #else /* !CONFIG_BUG */
  30. #ifndef HAVE_ARCH_BUG
  31. #define BUG()
  32. #endif
  33. #ifndef HAVE_ARCH_PAGE_BUG
  34. #define PAGE_BUG(page) do { if (page) ; } while (0)
  35. #endif
  36. #ifndef HAVE_ARCH_BUG_ON
  37. #define BUG_ON(condition) do { if (condition) ; } while(0)
  38. #endif
  39. #ifndef HAVE_ARCH_WARN_ON
  40. #define WARN_ON(condition) do { if (condition) ; } while(0)
  41. #endif
  42. #endif
  43. #endif