bug.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_S390_BUG_H
  3. #define _ASM_S390_BUG_H
  4. #include <linux/kernel.h>
  5. #ifdef CONFIG_BUG
  6. #ifdef CONFIG_DEBUG_BUGVERBOSE
  7. #define __EMIT_BUG(x) do { \
  8. asm volatile( \
  9. "0: j 0b+2\n" \
  10. "1:\n" \
  11. ".section .rodata.str,\"aMS\",@progbits,1\n" \
  12. "2: .asciz \""__FILE__"\"\n" \
  13. ".previous\n" \
  14. ".section __bug_table,\"aw\"\n" \
  15. "3: .long 1b-3b,2b-3b\n" \
  16. " .short %0,%1\n" \
  17. " .org 3b+%2\n" \
  18. ".previous\n" \
  19. : : "i" (__LINE__), \
  20. "i" (x), \
  21. "i" (sizeof(struct bug_entry))); \
  22. } while (0)
  23. #else /* CONFIG_DEBUG_BUGVERBOSE */
  24. #define __EMIT_BUG(x) do { \
  25. asm volatile( \
  26. "0: j 0b+2\n" \
  27. "1:\n" \
  28. ".section __bug_table,\"aw\"\n" \
  29. "2: .long 1b-2b\n" \
  30. " .short %0\n" \
  31. " .org 2b+%1\n" \
  32. ".previous\n" \
  33. : : "i" (x), \
  34. "i" (sizeof(struct bug_entry))); \
  35. } while (0)
  36. #endif /* CONFIG_DEBUG_BUGVERBOSE */
  37. #define BUG() do { \
  38. __EMIT_BUG(0); \
  39. unreachable(); \
  40. } while (0)
  41. #define __WARN_FLAGS(flags) do { \
  42. __EMIT_BUG(BUGFLAG_WARNING|(flags)); \
  43. } while (0)
  44. #define WARN_ON(x) ({ \
  45. int __ret_warn_on = !!(x); \
  46. if (__builtin_constant_p(__ret_warn_on)) { \
  47. if (__ret_warn_on) \
  48. __WARN(); \
  49. } else { \
  50. if (unlikely(__ret_warn_on)) \
  51. __WARN(); \
  52. } \
  53. unlikely(__ret_warn_on); \
  54. })
  55. #define HAVE_ARCH_BUG
  56. #define HAVE_ARCH_WARN_ON
  57. #endif /* CONFIG_BUG */
  58. #include <asm-generic/bug.h>
  59. #endif /* _ASM_S390_BUG_H */