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