bug.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef _PARISC_BUG_H
  2. #define _PARISC_BUG_H
  3. /*
  4. * Tell the user there is some problem.
  5. * The offending file and line are encoded in the __bug_table section.
  6. */
  7. #ifdef CONFIG_BUG
  8. #define HAVE_ARCH_BUG
  9. #define HAVE_ARCH_WARN_ON
  10. /* the break instruction is used as BUG() marker. */
  11. #define PARISC_BUG_BREAK_ASM "break 0x1f, 0x1fff"
  12. #define PARISC_BUG_BREAK_INSN 0x03ffe01f /* PARISC_BUG_BREAK_ASM */
  13. #if defined(CONFIG_64BIT)
  14. #define ASM_WORD_INSN ".dword\t"
  15. #else
  16. #define ASM_WORD_INSN ".word\t"
  17. #endif
  18. #ifdef CONFIG_DEBUG_BUGVERBOSE
  19. #define BUG() \
  20. do { \
  21. asm volatile("\n" \
  22. "1:\t" PARISC_BUG_BREAK_ASM "\n" \
  23. "\t.pushsection __bug_table,\"a\"\n" \
  24. "2:\t" ASM_WORD_INSN "1b, %c0\n" \
  25. "\t.short %c1, %c2\n" \
  26. "\t.org 2b+%c3\n" \
  27. "\t.popsection" \
  28. : : "i" (__FILE__), "i" (__LINE__), \
  29. "i" (0), "i" (sizeof(struct bug_entry)) ); \
  30. unreachable(); \
  31. } while(0)
  32. #else
  33. #define BUG() \
  34. do { \
  35. asm volatile(PARISC_BUG_BREAK_ASM : : ); \
  36. unreachable(); \
  37. } while(0)
  38. #endif
  39. #ifdef CONFIG_DEBUG_BUGVERBOSE
  40. #define __WARN_TAINT(taint) \
  41. do { \
  42. asm volatile("\n" \
  43. "1:\t" PARISC_BUG_BREAK_ASM "\n" \
  44. "\t.pushsection __bug_table,\"a\"\n" \
  45. "2:\t" ASM_WORD_INSN "1b, %c0\n" \
  46. "\t.short %c1, %c2\n" \
  47. "\t.org 2b+%c3\n" \
  48. "\t.popsection" \
  49. : : "i" (__FILE__), "i" (__LINE__), \
  50. "i" (BUGFLAG_TAINT(taint)), \
  51. "i" (sizeof(struct bug_entry)) ); \
  52. } while(0)
  53. #else
  54. #define __WARN_TAINT(taint) \
  55. do { \
  56. asm volatile("\n" \
  57. "1:\t" PARISC_BUG_BREAK_ASM "\n" \
  58. "\t.pushsection __bug_table,\"a\"\n" \
  59. "2:\t" ASM_WORD_INSN "1b\n" \
  60. "\t.short %c0\n" \
  61. "\t.org 2b+%c1\n" \
  62. "\t.popsection" \
  63. : : "i" (BUGFLAG_TAINT(taint)), \
  64. "i" (sizeof(struct bug_entry)) ); \
  65. } while(0)
  66. #endif
  67. #define WARN_ON(x) ({ \
  68. int __ret_warn_on = !!(x); \
  69. if (__builtin_constant_p(__ret_warn_on)) { \
  70. if (__ret_warn_on) \
  71. __WARN(); \
  72. } else { \
  73. if (unlikely(__ret_warn_on)) \
  74. __WARN(); \
  75. } \
  76. unlikely(__ret_warn_on); \
  77. })
  78. #endif
  79. #include <asm-generic/bug.h>
  80. #endif