Ghidra Decompiler Analysis Engine
types.h
1 /* ###
2  * IP: GHIDRA
3  * NOTE: Decompiler specific flags, refers to sparc,linux,windows,i386,apple,alpha,powerpc
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 /* typedefs for getting specific word sizes */
18 
19 /* Defines for the "preferred" intm size, where this is not determined by the */
20 /* algorithm being coded. I.e. the code works without change using */
21 /* maximum wordsize when compiled on 64 OR 32 machines */
22 
23 /* uintp is intended to be an unsigned integer that is the same size as a pointer */
24 
25 #ifndef __MYTYPES__
26 #define __MYTYPES__
27 
28 #if defined( __sparc )
29 #define HOST_ENDIAN 1
30 #if defined( __sparcv9 )
31 typedef unsigned long uintm;
32 typedef long intm;
33 typedef unsigned long uint8;
34 typedef long int8;
35 typedef unsigned int uint4;
36 typedef int int4;
37 typedef unsigned short uint2;
38 typedef short int2;
39 typedef unsigned char uint1;
40 typedef char int1;
41 typedef uint8 uintp;
42 #else
43 typedef unsigned int uintm;
44 typedef int intm;
45 
46 typedef unsigned long long uint8;
47 typedef long long int8;
48 typedef unsigned int uint4;
49 typedef int int4;
50 typedef unsigned short uint2;
51 typedef short int2;
52 typedef unsigned char uint1;
53 typedef char int1;
54 typedef uint4 uintp;
55 
56 #endif /* __sparcv9 */
57 #endif /* __sparc */
58 
59 /* Alpha defines */
60 #if defined (__digital__) && defined (__unix__)
61 typedef unsigned long uintm;
62 typedef long intm;
63 typedef unsigned long uint8;
64 typedef long int8;
65 typedef unsigned int uint4;
66 typedef int int4;
67 typedef unsigned short uint2;
68 typedef short int2;
69 typedef unsigned char uint1;
70 typedef char int1;
71 typedef uint8 uintp;
72 #endif
73 
74 #if defined (__linux__) && defined (__i386__)
75 #define HOST_ENDIAN 0
76 typedef unsigned long uintm;
77 typedef long intm;
78 typedef unsigned long long uint8;
79 typedef long long int8;
80 typedef unsigned int uint4;
81 typedef int int4;
82 typedef unsigned short uint2;
83 typedef short int2;
84 typedef unsigned char uint1;
85 typedef char int1;
86 typedef uint4 uintp;
87 #endif
88 
89 #if defined (__linux__) && defined (__x86_64__)
90 #define HOST_ENDIAN 0
91 typedef unsigned int uintm;
92 typedef int intm;
93 typedef unsigned long uint8;
94 typedef long int8;
95 typedef unsigned int uint4;
96 typedef int int4;
97 typedef unsigned short uint2;
98 typedef short int2;
99 typedef unsigned char uint1;
100 typedef char int1;
101 typedef uint8 uintp;
102 #endif
103 
104 #if defined(_WINDOWS)
105 
106 #if defined(_WIN64)
107 
108 #define HOST_ENDIAN 0
109 typedef unsigned int uintm;
110 typedef int intm;
111 typedef unsigned long long uint8;
112 typedef long long int8;
113 typedef unsigned int uint4;
114 typedef int int4;
115 typedef unsigned short uint2;
116 typedef short int2;
117 typedef unsigned char uint1;
118 typedef char int1;
119 typedef uint8 uintp;
120 
121 #else // _WIN32 assumed
122 
123 #define HOST_ENDIAN 0
124 typedef unsigned long uintm;
125 typedef long intm;
126 typedef unsigned long long uint8;
127 typedef long long int8;
128 typedef unsigned int uint4;
129 typedef int int4;
130 typedef unsigned short uint2;
131 typedef short int2;
132 typedef unsigned char uint1;
133 typedef char int1;
134 typedef uint4 uintp;
135 #endif // _WIN32
136 
137 #endif // _WINDOWS
138 
139 #if defined( __APPLE_CC__) && defined( __ppc__)
140 #define HOST_ENDIAN 1
141 typedef unsigned long uintm;
142 typedef long intm;
143 typedef unsigned long uint8;
144 typedef long int8;
145 typedef unsigned int uint4;
146 typedef int int4;
147 typedef unsigned short uint2;
148 typedef short int2;
149 typedef unsigned char uint1;
150 typedef char int1;
151 typedef uint4 uintp;
152 #endif
153 
154 #if defined( __APPLE_CC__) && defined( __i386__)
155 #define HOST_ENDIAN 0
156 typedef unsigned long uintm;
157 typedef long intm;
158 typedef unsigned long long uint8;
159 typedef long long int8;
160 typedef unsigned int uint4;
161 typedef int int4;
162 typedef unsigned short uint2;
163 typedef short int2;
164 typedef unsigned char uint1;
165 typedef char int1;
166 typedef uint4 uintp;
167 #endif
168 
169 #if defined (__APPLE_CC__) && defined (__x86_64__)
170 #define HOST_ENDIAN 0
171 typedef unsigned int uintm;
172 typedef int intm;
173 typedef unsigned long uint8;
174 typedef long int8;
175 typedef unsigned int uint4;
176 typedef int int4;
177 typedef unsigned short uint2;
178 typedef short int2;
179 typedef unsigned char uint1;
180 typedef char int1;
181 typedef uint8 uintp;
182 #endif
183 
184 #if defined (__APPLE_CC__) && defined (__aarch64__)
185 #define HOST_ENDIAN 0
186 typedef unsigned int uintm;
187 typedef int intm;
188 typedef unsigned long uint8;
189 typedef long int8;
190 typedef unsigned int uint4;
191 typedef int int4;
192 typedef unsigned short uint2;
193 typedef short int2;
194 typedef unsigned char uint1;
195 typedef char int1;
196 typedef uint8 uintp;
197 #endif
198 
199 #if defined(_WINDOWS)
200 #pragma warning (disable:4312)
201 #pragma warning (disable:4311)
202 #pragma warning (disable:4267)
203 #pragma warning (disable:4018)
204 #pragma warning (disable:4244)
205 
206 /*
207  The windows standard template library list implementation seems to have a philosophical difference with
208  the standard regarding the validity of iterators pointing to objects that are moved between containers
209  (via the splice method) These defines turn off the validity checks
210  (These have been moved to the VC project spec)
211  */
212 //#define _SECURE_SCL 0
213 //#define _HAS_ITERATOR_DEBUGGING 0
214 #endif
215 
216 /* In order to have a little more flexibility in integer precision vs efficiency,
217  we subdivide the integer types into three classes:
218 
219  Small integers: Integers that never come close to overflowing their (machine word)
220  precision. We will always use int4 or uint4 (or smaller) for
221  these so that the precision is explicitly given.
222 
223  Machine word integers: These integers exactly match the largest precision that
224  will fit in a general purpose register. They should be
225  used exclusively by in implementations of larger
226  precision objects. Use intm or uintm
227 
228  Big integers: These are intended to be arbitrary precison integers. However
229  for efficiency, these will always be implemented as fixed precision.
230  So for coding purposes, these should be interpreted as fixed
231  precision integers that store as big a number as you would ever need.
232 */
233 
234 /* Specify that unsigned big ints are coded with 8 bytes */
235 #define UINTB8
236 
237 typedef int8 intb; /* This is a signed big integer */
238 //#include "integer.hh"
239 #ifdef UINTB8
240 typedef uint8 uintb; /* This is an unsigned big integer */
241 #else
242 typedef uint4 uintb;
243 #endif
244 
245 /*
246 
247 Other compilation flags
248 
249 CPUI_DEBUG -- This is the ONE debug switch that should be passed in
250  from the compiler, all others are controlled below
251 */
252 
253 #ifdef CPUI_DEBUG
254 # define OPACTION_DEBUG
255 # define PRETTY_DEBUG
256 //# define __REMOTE_SOCKET__
257 //# define TYPEPROP_DEBUG
258 //# define DFSVERIFY_DEBUG
259 //# define BLOCKCONSISTENT_DEBUG
260 //# define MERGEMULTI_DEBUG
261 //# define VARBANK_DEBUG
262 #endif
263 
264 #endif