Print this page
11972 resync smatch
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/smatch/src/target.c
+++ new/usr/src/tools/smatch/src/target.c
1 1 #include <stdio.h>
2 2
3 3 #include "symbol.h"
4 4 #include "target.h"
5 +#include "machine.h"
5 6
6 7 struct symbol *size_t_ctype = &ulong_ctype;
7 8 struct symbol *ssize_t_ctype = &long_ctype;
9 +struct symbol *intmax_ctype = &llong_ctype;
10 +struct symbol *uintmax_ctype = &ullong_ctype;
11 +struct symbol *int64_ctype = &long_ctype;
12 +struct symbol *uint64_ctype = &ulong_ctype;
13 +struct symbol *int32_ctype = &int_ctype;
14 +struct symbol *uint32_ctype = &uint_ctype;
15 +struct symbol *wchar_ctype = &int_ctype;
16 +struct symbol *wint_ctype = &uint_ctype;
8 17
9 18 /*
10 19 * For "__attribute__((aligned))"
11 20 */
12 21 int max_alignment = 16;
13 22
14 23 /*
15 24 * Integer data types
16 25 */
17 26 int bits_in_bool = 1;
18 27 int bits_in_char = 8;
19 28 int bits_in_short = 16;
20 29 int bits_in_int = 32;
21 30 int bits_in_long = 32;
22 31 int bits_in_longlong = 64;
23 32 int bits_in_longlonglong = 128;
24 33
25 -int bits_in_wchar = 32;
26 -
27 34 int max_int_alignment = 4;
28 35
29 36 /*
30 37 * Floating point data types
31 38 */
32 39 int bits_in_float = 32;
33 40 int bits_in_double = 64;
34 -int bits_in_longdouble = 80;
41 +int bits_in_longdouble = 128;
35 42
36 -int max_fp_alignment = 8;
43 +int max_fp_alignment = 16;
37 44
38 45 /*
39 46 * Pointer data type
40 47 */
41 48 int bits_in_pointer = 32;
42 49 int pointer_alignment = 4;
43 50
44 51 /*
45 52 * Enum data types
46 53 */
47 54 int bits_in_enum = 32;
48 55 int enum_alignment = 4;
56 +
57 +
58 +void init_target(void)
59 +{
60 + switch (arch_mach) {
61 + case MACH_X86_64:
62 + if (arch_m64 == ARCH_LP64)
63 + break;
64 + /* fall through */
65 + case MACH_I386:
66 + case MACH_M68K:
67 + case MACH_SPARC32:
68 + case MACH_PPC32:
69 + wchar_ctype = &long_ctype;
70 + break;
71 + case MACH_ARM:
72 + case MACH_ARM64:
73 + wchar_ctype = &uint_ctype;
74 + break;
75 + default:
76 + break;
77 + }
78 +
79 + switch (arch_mach) {
80 + case MACH_MIPS64:
81 + if (arch_m64 == ARCH_LP64)
82 + break;
83 + /* fall through */
84 + case MACH_M68K:
85 + case MACH_SPARC32:
86 + case MACH_PPC32:
87 + case MACH_MIPS32:
88 + case MACH_RISCV32:
89 + arch_m64 = ARCH_LP32;
90 + int32_ctype = &long_ctype;
91 + uint32_ctype = &ulong_ctype;
92 + break;
93 + default:
94 + break;
95 + }
96 +
97 + switch (arch_mach) {
98 + case MACH_ARM:
99 + case MACH_MIPS32:
100 + case MACH_S390X:
101 + case MACH_SPARC32:
102 + bits_in_longdouble = 64;
103 + max_fp_alignment = 8;
104 + break;
105 + case MACH_X86_64:
106 + if (arch_m64 == ARCH_LP64 || arch_m64 == ARCH_X32)
107 + break;
108 + /* fall through */
109 + case MACH_I386:
110 + case MACH_M68K:
111 + bits_in_longdouble = 96;
112 + max_fp_alignment = 4;
113 + break;
114 + default:
115 + break;
116 + }
117 +
118 + switch (arch_m64) {
119 + case ARCH_X32:
120 + max_int_alignment = 8;
121 + int64_ctype = &llong_ctype;
122 + uint64_ctype = &ullong_ctype;
123 + break;
124 + case ARCH_LP32:
125 + /* default values */
126 + int64_ctype = &llong_ctype;
127 + uint64_ctype = &ullong_ctype;
128 + intmax_ctype = &llong_ctype;
129 + uintmax_ctype = &ullong_ctype;
130 + break;
131 + case ARCH_LP64:
132 + bits_in_long = 64;
133 + max_int_alignment = 8;
134 + size_t_ctype = &ulong_ctype;
135 + ssize_t_ctype = &long_ctype;
136 + intmax_ctype = &long_ctype;
137 + uintmax_ctype = &ulong_ctype;
138 + goto case_64bit_common;
139 + case ARCH_LLP64:
140 + bits_in_long = 32;
141 + max_int_alignment = 8;
142 + size_t_ctype = &ullong_ctype;
143 + ssize_t_ctype = &llong_ctype;
144 + int64_ctype = &llong_ctype;
145 + uint64_ctype = &ullong_ctype;
146 + goto case_64bit_common;
147 + case_64bit_common:
148 + bits_in_pointer = 64;
149 + pointer_alignment = 8;
150 + break;
151 + }
152 +
153 +#if defined(__CYGWIN__)
154 + wchar_ctype = &ushort_ctype;
155 +#endif
156 +#if defined(__FreeBSD__) || defined(__APPLE__)
157 + wint_ctype = &int_ctype;
158 +#endif
159 +#if defined(__APPLE__)
160 + int64_ctype = &llong_ctype;
161 + uint64_ctype = &ullong_ctype;
162 +#endif
163 +}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX