wined3d: Introduce wined3d_buffer_evict_sysmem().
[wine.git] / include / basetsd.h
blobf8553525f3784d62e83c29a54ecdf2a59be4c4ba
1 /*
2 * Compilers that uses ILP32, LP64 or P64 type models
3 * for both Win32 and Win64 are supported by this file.
5 * Copyright (C) 1999 Patrik Stridvall
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.
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.
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
22 #ifndef __WINE_BASETSD_H
23 #define __WINE_BASETSD_H
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /* defined(__cplusplus) */
30 * Win32 was easy to implement under Unix since most 32-bit Unices use the same
31 * type model (ILP32) as Win32, where int, long and pointer are 32-bit.
33 * Win64, however, can cause some problems. Most 64-bit Unices use the LP64 type
34 * model where int is 32-bit and long and pointer are 64-bit. Win64 on the other
35 * hand uses the LLP64 type model where int and long are 32 bit and pointer is
36 * 64-bit.
39 #if (defined(__x86_64__) || defined(__powerpc64__) || defined(__sparc64__) || defined(__aarch64__)) && !defined(_WIN64)
40 #define _WIN64
41 #endif
43 /* Type model independent typedefs */
44 /* The __intXX types are native types defined by the MS C compiler.
45 * Apps that make use of them before they get defined here, can
46 * simply add to the command line:
47 * -D__int8=char -D__int16=short -D__int32=int "-D__int64=long long"
49 #if !defined(_MSC_VER) && !defined(__WIDL__)
50 # ifndef __int8
51 # define __int8 char
52 # endif
53 # ifndef __int16
54 # define __int16 short
55 # endif
56 # ifndef __int32
57 # define __int32 int
58 # endif
59 # ifndef __int64
60 # if defined(_WIN64) && !defined(__MINGW64__)
61 # define __int64 long
62 # else
63 # define __int64 long long
64 # endif
65 # endif
66 #endif /* !defined(_MSC_VER) */
68 /* FIXME: DECLSPEC_ALIGN should be declared only in winnt.h, but we need it here too */
69 #ifndef DECLSPEC_ALIGN
70 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
71 # define DECLSPEC_ALIGN(x) __declspec(align(x))
72 # elif defined(__GNUC__)
73 # define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
74 # else
75 # define DECLSPEC_ALIGN(x)
76 # endif
77 #endif
79 typedef signed char INT8, *PINT8;
80 typedef signed short INT16, *PINT16;
81 typedef signed int INT32, *PINT32;
82 typedef unsigned char UINT8, *PUINT8;
83 typedef unsigned short UINT16, *PUINT16;
84 typedef unsigned int UINT32, *PUINT32;
85 typedef signed int LONG32, *PLONG32;
86 typedef unsigned int ULONG32, *PULONG32;
87 typedef unsigned int DWORD32, *PDWORD32;
89 #ifdef _MSC_VER
90 typedef signed __int64 INT64, *PINT64;
91 typedef unsigned __int64 UINT64, *PUINT64;
92 typedef signed __int64 LONG64, *PLONG64;
93 typedef unsigned __int64 ULONG64, *PULONG64;
94 typedef unsigned __int64 DWORD64, *PDWORD64;
95 #else
96 typedef signed __int64 DECLSPEC_ALIGN(8) INT64, *PINT64;
97 typedef unsigned __int64 DECLSPEC_ALIGN(8) UINT64, *PUINT64;
98 typedef signed __int64 DECLSPEC_ALIGN(8) LONG64, *PLONG64;
99 typedef unsigned __int64 DECLSPEC_ALIGN(8) ULONG64, *PULONG64;
100 typedef unsigned __int64 DECLSPEC_ALIGN(8) DWORD64, *PDWORD64;
101 #endif
103 /* Basic pointer-sized integer types */
105 #if defined(__midl) || defined(__WIDL__)
107 typedef /* [public] */ signed __int3264 INT_PTR, *PINT_PTR;
108 typedef /* [public] */ signed __int3264 LONG_PTR, *PLONG_PTR;
109 typedef /* [public] */ unsigned __int3264 UINT_PTR, *PUINT_PTR;
110 typedef /* [public] */ unsigned __int3264 ULONG_PTR, *PULONG_PTR;
111 typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
113 #elif defined(_WIN64)
115 #define __int3264 __int64
117 typedef signed __int64 INT_PTR, *PINT_PTR;
118 typedef signed __int64 LONG_PTR, *PLONG_PTR;
119 typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
120 typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
121 typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
123 #else
125 #define __int3264 __int32
127 typedef long INT_PTR, *PINT_PTR;
128 typedef unsigned long UINT_PTR, *PUINT_PTR;
129 typedef long LONG_PTR, *PLONG_PTR;
130 typedef unsigned long ULONG_PTR, *PULONG_PTR;
131 typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
133 #endif
135 /* Win32 or Win64 dependent typedef/defines. */
137 #ifdef _WIN64
139 #define MAXINT_PTR 0x7fffffffffffffff
140 #define MININT_PTR 0x8000000000000000
141 #define MAXUINT_PTR 0xffffffffffffffff
143 typedef __int64 SHANDLE_PTR;
144 typedef unsigned __int64 HANDLE_PTR;
145 typedef int HALF_PTR, *PHALF_PTR;
146 typedef unsigned int UHALF_PTR, *PUHALF_PTR;
148 #define MAXHALF_PTR 0x7fffffff
149 #define MINHALF_PTR 0x80000000
150 #define MAXUHALF_PTR 0xffffffff
152 #if !defined(__midl) && !defined(__WIDL__)
154 static inline ULONG32 HandleToULong(const void *h)
156 return (ULONG32)(ULONG_PTR)h;
159 static inline LONG32 HandleToLong(const void *h)
161 return (LONG32)(LONG_PTR)h;
164 static inline void *ULongToHandle(ULONG32 ul)
166 return (void *)(ULONG_PTR)ul;
169 static inline void *LongToHandle(LONG32 l)
171 return (void *)(LONG_PTR)l;
174 static inline ULONG32 PtrToUlong(const void *p)
176 return (ULONG32)(ULONG_PTR)p;
179 static inline LONG32 PtrToLong(const void *p)
181 return (LONG32)(LONG_PTR)p;
184 static inline UINT32 PtrToUint(const void *p)
186 return (UINT32)(UINT_PTR)p;
189 static inline INT32 PtrToInt(const void *p)
191 return (INT32)(INT_PTR)p;
194 static inline UINT16 PtrToUshort(const void *p)
196 return (UINT16)(ULONG_PTR)p;
199 static inline INT16 PtrToShort(const void *p)
201 return (INT16)(LONG_PTR)p;
204 static inline void *IntToPtr(INT32 i)
206 return (void *)(INT_PTR)i;
209 static inline void *UIntToPtr(UINT32 ui)
211 return (void *)(UINT_PTR)ui;
214 static inline void *LongToPtr(LONG32 l)
216 return (void *)(LONG_PTR)l;
219 static inline void *ULongToPtr(ULONG32 ul)
221 return (void *)(ULONG_PTR)ul;
224 #endif /* !__midl && !__WIDL__ */
226 #else /* FIXME: defined(_WIN32) */
228 #define MAXINT_PTR 0x7fffffff
229 #define MININT_PTR 0x80000000
230 #define MAXUINT_PTR 0xffffffff
232 typedef long SHANDLE_PTR;
233 typedef unsigned long HANDLE_PTR;
234 typedef signed short HALF_PTR, *PHALF_PTR;
235 typedef unsigned short UHALF_PTR, *PUHALF_PTR;
237 #define MAXUHALF_PTR 0xffff
238 #define MAXHALF_PTR 0x7fff
239 #define MINHALF_PTR 0x8000
241 #define HandleToULong(h) ((ULONG)(ULONG_PTR)(h))
242 #define HandleToLong(h) ((LONG)(LONG_PTR)(h))
243 #define ULongToHandle(ul) ((HANDLE)(ULONG_PTR)(ul))
244 #define LongToHandle(l) ((HANDLE)(LONG_PTR)(l))
245 #define PtrToUlong(p) ((ULONG)(ULONG_PTR)(p))
246 #define PtrToLong(p) ((LONG)(LONG_PTR)(p))
247 #define PtrToUint(p) ((UINT)(UINT_PTR)(p))
248 #define PtrToInt(p) ((INT)(INT_PTR)(p))
249 #define PtrToUshort(p) ((USHORT)(ULONG_PTR)(p))
250 #define PtrToShort(p) ((SHORT)(LONG_PTR)(p))
251 #define IntToPtr(i) ((void *)(INT_PTR)((INT)i))
252 #define UIntToPtr(ui) ((void *)(UINT_PTR)((UINT)ui))
253 #define LongToPtr(l) ((void *)(LONG_PTR)((LONG)l))
254 #define ULongToPtr(ul) ((void *)(ULONG_PTR)((ULONG)ul))
256 #endif /* defined(_WIN64) || defined(_WIN32) */
258 #define HandleToUlong(h) HandleToULong(h)
259 #define UlongToHandle(ul) ULongToHandle(ul)
260 #define UintToPtr(ui) UIntToPtr(ui)
261 #define UlongToPtr(ul) ULongToPtr(ul)
263 typedef LONG_PTR SSIZE_T, *PSSIZE_T;
264 typedef ULONG_PTR SIZE_T, *PSIZE_T;
266 typedef ULONG_PTR KAFFINITY, *PKAFFINITY;
268 /* Some Wine-specific definitions */
270 /* Architecture dependent settings. */
271 /* These are hardcoded to avoid dependencies on config.h in Winelib apps. */
272 #if defined(__i386__)
273 # undef WORDS_BIGENDIAN
274 # undef BITFIELDS_BIGENDIAN
275 # define ALLOW_UNALIGNED_ACCESS
276 #elif defined(__x86_64__)
277 # undef WORDS_BIGENDIAN
278 # undef BITFIELDS_BIGENDIAN
279 # define ALLOW_UNALIGNED_ACCESS
280 #elif defined(__sparc__)
281 # define WORDS_BIGENDIAN
282 # define BITFIELDS_BIGENDIAN
283 # undef ALLOW_UNALIGNED_ACCESS
284 #elif defined(__powerpc__)
285 # define WORDS_BIGENDIAN
286 # define BITFIELDS_BIGENDIAN
287 # undef ALLOW_UNALIGNED_ACCESS
288 #elif defined(__ALPHA__)
289 # undef WORDS_BIGENDIAN
290 # undef BITFIELDS_BIGENDIAN
291 # undef ALLOW_UNALIGNED_ACCESS
292 #elif defined(__ARMEB__)
293 # define WORDS_BIGENDIAN
294 # define BITFIELDS_BIGENDIAN
295 # undef ALLOW_UNALIGNED_ACCESS
296 #elif defined(__ARMEL__) || defined(__arm__)
297 # undef WORDS_BIGENDIAN
298 # undef BITFIELDS_BIGENDIAN
299 # undef ALLOW_UNALIGNED_ACCESS
300 #elif defined(__AARCH64EB__)
301 # define WORDS_BIGENDIAN
302 # define BITFIELDS_BIGENDIAN
303 # undef ALLOW_UNALIGNED_ACCESS
304 #elif defined(__AARCH64EL__) || defined(__aarch64__)
305 # undef WORDS_BIGENDIAN
306 # undef BITFIELDS_BIGENDIAN
307 # undef ALLOW_UNALIGNED_ACCESS
308 #elif defined(__MIPSEB__)
309 # define WORDS_BIGENDIAN
310 # define BITFIELDS_BIGENDIAN
311 # undef ALLOW_UNALIGNED_ACCESS
312 #elif defined(__MIPSEL__)
313 # undef WORDS_BIGENDIAN
314 # undef BITFIELDS_BIGENDIAN
315 # undef ALLOW_UNALIGNED_ACCESS
316 #elif !defined(RC_INVOKED) && !defined(__WIDL__) && !defined(__midl)
317 # error Unknown CPU architecture!
318 #endif
320 #ifdef __cplusplus
321 } /* extern "C" */
322 #endif /* defined(__cplusplus) */
324 #endif /* !defined(__WINE_BASETSD_H) */