bug.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #ifdef CONFIG_64BIT
  14. #define ASM_ULONG_INSN ".dword"
  15. #else
  16. #define ASM_ULONG_INSN ".word"
  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_ULONG_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. for(;;) ; \
  31. } while(0)
  32. #else
  33. #define BUG() \
  34. do { \
  35. asm volatile(PARISC_BUG_BREAK_ASM : : ); \
  36. for(;;) ; \
  37. } while(0)
  38. #endif
  39. #define __WARN() \
  40. do { \
  41. asm volatile("\n" \
  42. "1:\t" PARISC_BUG_BREAK_ASM "\n" \
  43. "\t.pushsection __bug_table,\"a\"\n" \
  44. "2:\t" ASM_ULONG_INSN " 1b, %c0\n" \
  45. "\t.short %c1, %c2\n" \
  46. "\t.org 2b+%c3\n" \
  47. "\t.popsection" \
  48. : : "i" (__FILE__), "i" (__LINE__), \
  49. "i" (BUGFLAG_WARNING), \
  50. "i" (sizeof(struct bug_entry)) ); \
  51. } while(0)
  52. #define WARN_ON(x) ({ \
  53. typeof(x) __ret_warn_on = (x); \
  54. if (__builtin_constant_p(__ret_warn_on)) { \
  55. if (__ret_warn_on) \
  56. __WARN(); \
  57. } else { \
  58. if (unlikely(__ret_warn_on)) \
  59. __WARN(); \
  60. } \
  61. unlikely(__ret_warn_on); \
  62. })
  63. #endif
  64. #include <asm-generic/bug.h>
  65. #endif