bug.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef _PPC_BUG_H
  2. #define _PPC_BUG_H
  3. struct bug_entry {
  4. unsigned long bug_addr;
  5. int line;
  6. const char *file;
  7. const char *function;
  8. };
  9. /*
  10. * If this bit is set in the line number it means that the trap
  11. * is for WARN_ON rather than BUG or BUG_ON.
  12. */
  13. #define BUG_WARNING_TRAP 0x1000000
  14. #ifdef CONFIG_BUG
  15. #define BUG() do { \
  16. __asm__ __volatile__( \
  17. "1: twi 31,0,0\n" \
  18. ".section __bug_table,\"a\"\n\t" \
  19. " .long 1b,%0,%1,%2\n" \
  20. ".previous" \
  21. : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \
  22. } while (0)
  23. #define BUG_ON(x) do { \
  24. if (!__builtin_constant_p(x) || (x)) { \
  25. __asm__ __volatile__( \
  26. "1: twnei %0,0\n" \
  27. ".section __bug_table,\"a\"\n\t" \
  28. " .long 1b,%1,%2,%3\n" \
  29. ".previous" \
  30. : : "r" (x), "i" (__LINE__), "i" (__FILE__), \
  31. "i" (__FUNCTION__)); \
  32. } \
  33. } while (0)
  34. #define WARN_ON(x) do { \
  35. if (!__builtin_constant_p(x) || (x)) { \
  36. __asm__ __volatile__( \
  37. "1: twnei %0,0\n" \
  38. ".section __bug_table,\"a\"\n\t" \
  39. " .long 1b,%1,%2,%3\n" \
  40. ".previous" \
  41. : : "r" (x), "i" (__LINE__ + BUG_WARNING_TRAP), \
  42. "i" (__FILE__), "i" (__FUNCTION__)); \
  43. } \
  44. } while (0)
  45. #define HAVE_ARCH_BUG
  46. #define HAVE_ARCH_BUG_ON
  47. #define HAVE_ARCH_WARN_ON
  48. #endif
  49. #include <asm-generic/bug.h>
  50. #endif