ubsan.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LIB_UBSAN_H
  3. #define _LIB_UBSAN_H
  4. enum {
  5. type_kind_int = 0,
  6. type_kind_float = 1,
  7. type_unknown = 0xffff
  8. };
  9. struct type_descriptor {
  10. u16 type_kind;
  11. u16 type_info;
  12. char type_name[1];
  13. };
  14. struct source_location {
  15. const char *file_name;
  16. union {
  17. unsigned long reported;
  18. struct {
  19. u32 line;
  20. u32 column;
  21. };
  22. };
  23. };
  24. struct overflow_data {
  25. struct source_location location;
  26. struct type_descriptor *type;
  27. };
  28. struct type_mismatch_data {
  29. struct source_location location;
  30. struct type_descriptor *type;
  31. unsigned long alignment;
  32. unsigned char type_check_kind;
  33. };
  34. struct type_mismatch_data_v1 {
  35. struct source_location location;
  36. struct type_descriptor *type;
  37. unsigned char log_alignment;
  38. unsigned char type_check_kind;
  39. };
  40. struct type_mismatch_data_common {
  41. struct source_location *location;
  42. struct type_descriptor *type;
  43. unsigned long alignment;
  44. unsigned char type_check_kind;
  45. };
  46. struct nonnull_arg_data {
  47. struct source_location location;
  48. struct source_location attr_location;
  49. int arg_index;
  50. };
  51. struct vla_bound_data {
  52. struct source_location location;
  53. struct type_descriptor *type;
  54. };
  55. struct out_of_bounds_data {
  56. struct source_location location;
  57. struct type_descriptor *array_type;
  58. struct type_descriptor *index_type;
  59. };
  60. struct shift_out_of_bounds_data {
  61. struct source_location location;
  62. struct type_descriptor *lhs_type;
  63. struct type_descriptor *rhs_type;
  64. };
  65. struct unreachable_data {
  66. struct source_location location;
  67. };
  68. struct invalid_value_data {
  69. struct source_location location;
  70. struct type_descriptor *type;
  71. };
  72. #if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__)
  73. typedef __int128 s_max;
  74. typedef unsigned __int128 u_max;
  75. #else
  76. typedef s64 s_max;
  77. typedef u64 u_max;
  78. #endif
  79. #endif