bug.h 858 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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_BUG_ON
  13. #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
  14. #endif
  15. #ifndef HAVE_ARCH_WARN_ON
  16. #define WARN_ON(condition) do { \
  17. if (unlikely((condition)!=0)) { \
  18. printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
  19. dump_stack(); \
  20. } \
  21. } while (0)
  22. #endif
  23. #else /* !CONFIG_BUG */
  24. #ifndef HAVE_ARCH_BUG
  25. #define BUG()
  26. #endif
  27. #ifndef HAVE_ARCH_BUG_ON
  28. #define BUG_ON(condition) do { if (condition) ; } while(0)
  29. #endif
  30. #ifndef HAVE_ARCH_WARN_ON
  31. #define WARN_ON(condition) do { if (condition) ; } while(0)
  32. #endif
  33. #endif
  34. #endif