1 | /*
|
---|
2 | * Compilers that uses ILP32, LP64 or P64 type models
|
---|
3 | * for both Win32 and Win64 are supported by this file.
|
---|
4 | *
|
---|
5 | * Copyright (C) 1999 Patrik Stridvall
|
---|
6 | *
|
---|
7 | * This library is free software; you can redistribute it and/or
|
---|
8 | * modify it under the terms of the GNU Lesser General Public
|
---|
9 | * License as published by the Free Software Foundation; either
|
---|
10 | * version 2.1 of the License, or (at your option) any later version.
|
---|
11 | *
|
---|
12 | * This library is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
15 | * Lesser General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU Lesser General Public
|
---|
18 | * License along with this library; if not, write to the Free Software
|
---|
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
---|
20 | */
|
---|
21 |
|
---|
22 | /*
|
---|
23 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
24 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
25 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
26 | * a choice of LGPL license versions is made available with the language indicating
|
---|
27 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
28 | * of the LGPL is applied is otherwise unspecified.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #ifndef __WINE_BASETSD_H
|
---|
32 | #define __WINE_BASETSD_H
|
---|
33 |
|
---|
34 | #ifdef __cplusplus
|
---|
35 | extern "C" {
|
---|
36 | #endif /* defined(__cplusplus) */
|
---|
37 |
|
---|
38 | /*
|
---|
39 | * Win32 was easy to implement under Unix since most (all?) 32-bit
|
---|
40 | * Unices uses the same type model (ILP32) as Win32, where int, long
|
---|
41 | * and pointer are 32-bit.
|
---|
42 | *
|
---|
43 | * Win64, however, will cause some problems when implemented under Unix.
|
---|
44 | * Linux/{Alpha, Sparc64} and most (all?) other 64-bit Unices use
|
---|
45 | * the LP64 type model where int is 32-bit and long and pointer are
|
---|
46 | * 64-bit. Win64 on the other hand uses the P64 (sometimes called LLP64)
|
---|
47 | * type model where int and long are 32 bit and pointer is 64-bit.
|
---|
48 | */
|
---|
49 |
|
---|
50 | #if defined(__x86_64__) && !defined(_WIN64)
|
---|
51 | #define _WIN64
|
---|
52 | #endif
|
---|
53 |
|
---|
54 | /* Type model independent typedefs */
|
---|
55 | /* The __intXX types are native types defined by the MS C compiler.
|
---|
56 | * Apps that make use of them before they get defined here, can
|
---|
57 | * simply add to the command line:
|
---|
58 | * -D__int8=char -D__int16=short -D__int32=int "-D__int64=long long"
|
---|
59 | */
|
---|
60 | #if !defined(_MSC_VER) && !defined(__WIDL__)
|
---|
61 | # ifndef __int8
|
---|
62 | # define __int8 char
|
---|
63 | # endif
|
---|
64 | # ifndef __int16
|
---|
65 | # define __int16 short
|
---|
66 | # endif
|
---|
67 | # ifndef __int32
|
---|
68 | # define __int32 int
|
---|
69 | # endif
|
---|
70 | # ifndef __int64
|
---|
71 | # if defined(_WIN64) && !defined(__MINGW64__)
|
---|
72 | # define __int64 long
|
---|
73 | # else
|
---|
74 | # define __int64 long long
|
---|
75 | # endif
|
---|
76 | # endif
|
---|
77 | #endif /* !defined(_MSC_VER) */
|
---|
78 |
|
---|
79 | /* FIXME: DECLSPEC_ALIGN should be declared only in winnt.h, but we need it here too */
|
---|
80 | #ifndef DECLSPEC_ALIGN
|
---|
81 | # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
|
---|
82 | # define DECLSPEC_ALIGN(x) __declspec(align(x))
|
---|
83 | # elif defined(__GNUC__)
|
---|
84 | # define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
|
---|
85 | # else
|
---|
86 | # define DECLSPEC_ALIGN(x)
|
---|
87 | # endif
|
---|
88 | #endif
|
---|
89 |
|
---|
90 | typedef signed char INT8, *PINT8;
|
---|
91 | typedef signed short INT16, *PINT16;
|
---|
92 | typedef signed int INT32, *PINT32;
|
---|
93 | typedef unsigned char UINT8, *PUINT8;
|
---|
94 | typedef unsigned short UINT16, *PUINT16;
|
---|
95 | typedef unsigned int UINT32, *PUINT32;
|
---|
96 | typedef signed int LONG32, *PLONG32;
|
---|
97 | typedef unsigned int ULONG32, *PULONG32;
|
---|
98 | typedef unsigned int DWORD32, *PDWORD32;
|
---|
99 |
|
---|
100 | #ifdef _MSC_VER
|
---|
101 | typedef signed __int64 INT64, *PINT64;
|
---|
102 | typedef unsigned __int64 UINT64, *PUINT64;
|
---|
103 | typedef signed __int64 LONG64, *PLONG64;
|
---|
104 | typedef unsigned __int64 ULONG64, *PULONG64;
|
---|
105 | typedef unsigned __int64 DWORD64, *PDWORD64;
|
---|
106 | #else
|
---|
107 | typedef signed __int64 DECLSPEC_ALIGN(8) INT64, *PINT64;
|
---|
108 | typedef unsigned __int64 DECLSPEC_ALIGN(8) UINT64, *PUINT64;
|
---|
109 | typedef signed __int64 DECLSPEC_ALIGN(8) LONG64, *PLONG64;
|
---|
110 | typedef unsigned __int64 DECLSPEC_ALIGN(8) ULONG64, *PULONG64;
|
---|
111 | typedef unsigned __int64 DECLSPEC_ALIGN(8) DWORD64, *PDWORD64;
|
---|
112 | #endif
|
---|
113 |
|
---|
114 | /* Basic pointer-sized integer types */
|
---|
115 |
|
---|
116 | #if defined(__midl) || defined(__WIDL__)
|
---|
117 |
|
---|
118 | typedef /* [public] */ signed __int3264 INT_PTR, *PINT_PTR;
|
---|
119 | typedef /* [public] */ signed __int3264 LONG_PTR, *PLONG_PTR;
|
---|
120 | typedef /* [public] */ unsigned __int3264 UINT_PTR, *PUINT_PTR;
|
---|
121 | typedef /* [public] */ unsigned __int3264 ULONG_PTR, *PULONG_PTR;
|
---|
122 | typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
|
---|
123 |
|
---|
124 | #elif defined(_WIN64)
|
---|
125 |
|
---|
126 | #define __int3264 __int64
|
---|
127 |
|
---|
128 | typedef signed __int64 INT_PTR, *PINT_PTR;
|
---|
129 | typedef signed __int64 LONG_PTR, *PLONG_PTR;
|
---|
130 | typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
|
---|
131 | typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
|
---|
132 | typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
|
---|
133 |
|
---|
134 | #else
|
---|
135 |
|
---|
136 | #define __int3264 __int32
|
---|
137 |
|
---|
138 | typedef long INT_PTR, *PINT_PTR;
|
---|
139 | typedef unsigned long UINT_PTR, *PUINT_PTR;
|
---|
140 | typedef long LONG_PTR, *PLONG_PTR;
|
---|
141 | typedef unsigned long ULONG_PTR, *PULONG_PTR;
|
---|
142 | typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
|
---|
143 |
|
---|
144 | #endif
|
---|
145 |
|
---|
146 | /* Win32 or Win64 dependent typedef/defines. */
|
---|
147 |
|
---|
148 | #ifdef _WIN64
|
---|
149 |
|
---|
150 | #define MAXINT_PTR 0x7fffffffffffffff
|
---|
151 | #define MININT_PTR 0x8000000000000000
|
---|
152 | #define MAXUINT_PTR 0xffffffffffffffff
|
---|
153 |
|
---|
154 | typedef __int64 SHANDLE_PTR;
|
---|
155 | typedef unsigned __int64 HANDLE_PTR;
|
---|
156 | typedef int HALF_PTR, *PHALF_PTR;
|
---|
157 | typedef unsigned int UHALF_PTR, *PUHALF_PTR;
|
---|
158 |
|
---|
159 | #define MAXHALF_PTR 0x7fffffff
|
---|
160 | #define MINHALF_PTR 0x80000000
|
---|
161 | #define MAXUHALF_PTR 0xffffffff
|
---|
162 |
|
---|
163 | #if !defined(__midl) && !defined(__WIDL__)
|
---|
164 |
|
---|
165 | static inline ULONG32 HandleToULong(const void *h)
|
---|
166 | {
|
---|
167 | return (ULONG_PTR)h;
|
---|
168 | }
|
---|
169 |
|
---|
170 | static inline LONG32 HandleToLong(const void *h)
|
---|
171 | {
|
---|
172 | return (LONG_PTR)h;
|
---|
173 | }
|
---|
174 |
|
---|
175 | static inline void *ULongToHandle(ULONG32 ul)
|
---|
176 | {
|
---|
177 | return (void *)(ULONG_PTR)ul;
|
---|
178 | }
|
---|
179 |
|
---|
180 | static inline void *LongToHandle(LONG32 l)
|
---|
181 | {
|
---|
182 | return (void *)(LONG_PTR)l;
|
---|
183 | }
|
---|
184 |
|
---|
185 | static inline ULONG32 PtrToUlong(const void *p)
|
---|
186 | {
|
---|
187 | return (ULONG_PTR)p;
|
---|
188 | }
|
---|
189 |
|
---|
190 | static inline LONG32 PtrToLong(const void *p)
|
---|
191 | {
|
---|
192 | return (LONG_PTR)p;
|
---|
193 | }
|
---|
194 |
|
---|
195 | static inline UINT32 PtrToUint(const void *p)
|
---|
196 | {
|
---|
197 | return (UINT_PTR)p;
|
---|
198 | }
|
---|
199 |
|
---|
200 | static inline INT32 PtrToInt(const void *p)
|
---|
201 | {
|
---|
202 | return (INT_PTR)p;
|
---|
203 | }
|
---|
204 |
|
---|
205 | static inline UINT16 PtrToUshort(const void *p)
|
---|
206 | {
|
---|
207 | return (ULONG_PTR)p;
|
---|
208 | }
|
---|
209 |
|
---|
210 | static inline INT16 PtrToShort(const void *p)
|
---|
211 | {
|
---|
212 | return (LONG_PTR)p;
|
---|
213 | }
|
---|
214 |
|
---|
215 | static inline void *IntToPtr(INT32 i)
|
---|
216 | {
|
---|
217 | return (void *)(INT_PTR)i;
|
---|
218 | }
|
---|
219 |
|
---|
220 | static inline void *UIntToPtr(UINT32 ui)
|
---|
221 | {
|
---|
222 | return (void *)(UINT_PTR)ui;
|
---|
223 | }
|
---|
224 |
|
---|
225 | static inline void *LongToPtr(LONG32 l)
|
---|
226 | {
|
---|
227 | return (void *)(LONG_PTR)l;
|
---|
228 | }
|
---|
229 |
|
---|
230 | static inline void *ULongToPtr(ULONG32 ul)
|
---|
231 | {
|
---|
232 | return (void *)(ULONG_PTR)ul;
|
---|
233 | }
|
---|
234 |
|
---|
235 | #endif /* !__midl && !__WIDL__ */
|
---|
236 |
|
---|
237 | #else /* FIXME: defined(_WIN32) */
|
---|
238 |
|
---|
239 | #define MAXINT_PTR 0x7fffffff
|
---|
240 | #define MININT_PTR 0x80000000
|
---|
241 | #define MAXUINT_PTR 0xffffffff
|
---|
242 |
|
---|
243 | typedef long SHANDLE_PTR;
|
---|
244 | typedef unsigned long HANDLE_PTR;
|
---|
245 | typedef signed short HALF_PTR, *PHALF_PTR;
|
---|
246 | typedef unsigned short UHALF_PTR, *PUHALF_PTR;
|
---|
247 |
|
---|
248 | #define MAXUHALF_PTR 0xffff
|
---|
249 | #define MAXHALF_PTR 0x7fff
|
---|
250 | #define MINHALF_PTR 0x8000
|
---|
251 |
|
---|
252 | #define HandleToULong(h) ((ULONG)(ULONG_PTR)(h))
|
---|
253 | #define HandleToLong(h) ((LONG)(LONG_PTR)(h))
|
---|
254 | #define ULongToHandle(ul) ((HANDLE)(ULONG_PTR)(ul))
|
---|
255 | #define LongToHandle(l) ((HANDLE)(LONG_PTR)(l))
|
---|
256 | #define PtrToUlong(p) ((ULONG)(ULONG_PTR)(p))
|
---|
257 | #define PtrToLong(p) ((LONG)(LONG_PTR)(p))
|
---|
258 | #define PtrToUint(p) ((UINT)(UINT_PTR)(p))
|
---|
259 | #define PtrToInt(p) ((INT)(INT_PTR)(p))
|
---|
260 | #define PtrToUshort(p) ((USHORT)(ULONG_PTR)(p))
|
---|
261 | #define PtrToShort(p) ((SHORT)(LONG_PTR)(p))
|
---|
262 | #define IntToPtr(i) ((void *)(INT_PTR)((INT)i))
|
---|
263 | #define UIntToPtr(ui) ((void *)(UINT_PTR)((UINT)ui))
|
---|
264 | #define LongToPtr(l) ((void *)(LONG_PTR)((LONG)l))
|
---|
265 | #define ULongToPtr(ul) ((void *)(ULONG_PTR)((ULONG)ul))
|
---|
266 |
|
---|
267 | #endif /* defined(_WIN64) || defined(_WIN32) */
|
---|
268 |
|
---|
269 | #define HandleToUlong(h) HandleToULong(h)
|
---|
270 | #define UlongToHandle(ul) ULongToHandle(ul)
|
---|
271 | #define UintToPtr(ui) UIntToPtr(ui)
|
---|
272 | #define UlongToPtr(ul) ULongToPtr(ul)
|
---|
273 |
|
---|
274 | typedef LONG_PTR SSIZE_T, *PSSIZE_T;
|
---|
275 | typedef ULONG_PTR SIZE_T, *PSIZE_T;
|
---|
276 |
|
---|
277 | typedef ULONG_PTR KAFFINITY, *PKAFFINITY;
|
---|
278 |
|
---|
279 | /* Some Wine-specific definitions */
|
---|
280 |
|
---|
281 | /* Architecture dependent settings. */
|
---|
282 | /* These are hardcoded to avoid dependencies on config.h in Winelib apps. */
|
---|
283 | #if defined(__i386__)
|
---|
284 | # undef WORDS_BIGENDIAN
|
---|
285 | # undef BITFIELDS_BIGENDIAN
|
---|
286 | # define ALLOW_UNALIGNED_ACCESS
|
---|
287 | #elif defined(__x86_64__)
|
---|
288 | # undef WORDS_BIGENDIAN
|
---|
289 | # undef BITFIELDS_BIGENDIAN
|
---|
290 | # define ALLOW_UNALIGNED_ACCESS
|
---|
291 | #elif defined(__sparc__)
|
---|
292 | # define WORDS_BIGENDIAN
|
---|
293 | # define BITFIELDS_BIGENDIAN
|
---|
294 | # undef ALLOW_UNALIGNED_ACCESS
|
---|
295 | #elif defined(__powerpc__)
|
---|
296 | # define WORDS_BIGENDIAN
|
---|
297 | # define BITFIELDS_BIGENDIAN
|
---|
298 | # undef ALLOW_UNALIGNED_ACCESS
|
---|
299 | #elif defined(__ALPHA__)
|
---|
300 | # undef WORDS_BIGENDIAN
|
---|
301 | # undef BITFIELDS_BIGENDIAN
|
---|
302 | # undef ALLOW_UNALIGNED_ACCESS
|
---|
303 | #elif !defined(RC_INVOKED) && !defined(__WIDL__) && !defined(__midl)
|
---|
304 | # error Unknown CPU architecture!
|
---|
305 | #endif
|
---|
306 |
|
---|
307 | #ifdef __cplusplus
|
---|
308 | } /* extern "C" */
|
---|
309 | #endif /* defined(__cplusplus) */
|
---|
310 |
|
---|
311 | #endif /* !defined(__WINE_BASETSD_H) */
|
---|