1 |
bearsoft |
1.1 |
/*++
|
2 |
|
|
|
3 |
|
|
Copyright (c) 1997-1999 Microsoft Corporation
|
4 |
|
|
|
5 |
|
|
Module Name:
|
6 |
|
|
|
7 |
|
|
basetsd.h
|
8 |
|
|
|
9 |
|
|
Abstract:
|
10 |
|
|
|
11 |
|
|
Type definitions for the basic sized types.
|
12 |
|
|
|
13 |
|
|
Author:
|
14 |
|
|
|
15 |
|
|
Jeff Havens (jhavens) 23-Oct-1997
|
16 |
|
|
|
17 |
|
|
Revision History:
|
18 |
|
|
|
19 |
|
|
--*/
|
20 |
|
|
|
21 |
|
|
#ifndef _BASETSD_H_
|
22 |
|
|
#define _BASETSD_H_
|
23 |
|
|
|
24 |
|
|
#if _MSC_VER > 1000
|
25 |
|
|
#pragma once
|
26 |
|
|
#endif
|
27 |
|
|
|
28 |
|
|
#ifdef __cplusplus
|
29 |
|
|
extern "C" {
|
30 |
|
|
#endif
|
31 |
|
|
|
32 |
|
|
typedef signed char INT8, *PINT8;
|
33 |
|
|
typedef signed short INT16, *PINT16;
|
34 |
|
|
typedef signed int INT32, *PINT32;
|
35 |
|
|
typedef signed __int64 INT64, *PINT64;
|
36 |
|
|
typedef unsigned char UINT8, *PUINT8;
|
37 |
|
|
typedef unsigned short UINT16, *PUINT16;
|
38 |
|
|
typedef unsigned int UINT32, *PUINT32;
|
39 |
|
|
typedef unsigned __int64 UINT64, *PUINT64;
|
40 |
|
|
|
41 |
|
|
//
|
42 |
|
|
// The following types are guaranteed to be signed and 32 bits wide.
|
43 |
|
|
//
|
44 |
|
|
|
45 |
|
|
typedef signed int LONG32, *PLONG32;
|
46 |
|
|
|
47 |
|
|
//
|
48 |
|
|
// The following types are guaranteed to be unsigned and 32 bits wide.
|
49 |
|
|
//
|
50 |
|
|
|
51 |
|
|
typedef unsigned int ULONG32, *PULONG32;
|
52 |
|
|
typedef unsigned int DWORD32, *PDWORD32;
|
53 |
|
|
|
54 |
|
|
#if !defined(_W64)
|
55 |
|
|
#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
|
56 |
|
|
#define _W64 __w64
|
57 |
|
|
#else
|
58 |
|
|
#define _W64
|
59 |
|
|
#endif
|
60 |
|
|
#endif
|
61 |
|
|
|
62 |
|
|
//
|
63 |
|
|
// The INT_PTR is guaranteed to be the same size as a pointer. Its
|
64 |
|
|
// size with change with pointer size (32/64). It should be used
|
65 |
|
|
// anywhere that a pointer is cast to an integer type. UINT_PTR is
|
66 |
|
|
// the unsigned variation.
|
67 |
|
|
//
|
68 |
|
|
// __int3264 is intrinsic to 64b MIDL but not to old MIDL or to C compiler.
|
69 |
|
|
//
|
70 |
|
|
#if ( 501 < __midl )
|
71 |
|
|
|
72 |
|
|
typedef [public] __int3264 INT_PTR, *PINT_PTR;
|
73 |
|
|
typedef [public] unsigned __int3264 UINT_PTR, *PUINT_PTR;
|
74 |
|
|
|
75 |
|
|
typedef [public] __int3264 LONG_PTR, *PLONG_PTR;
|
76 |
|
|
typedef [public] unsigned __int3264 ULONG_PTR, *PULONG_PTR;
|
77 |
|
|
|
78 |
|
|
#else // midl64
|
79 |
|
|
// old midl and C++ compiler
|
80 |
|
|
|
81 |
|
|
#if defined(_WIN64)
|
82 |
|
|
typedef __int64 INT_PTR, *PINT_PTR;
|
83 |
|
|
typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
|
84 |
|
|
|
85 |
|
|
typedef __int64 LONG_PTR, *PLONG_PTR;
|
86 |
|
|
typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
|
87 |
|
|
|
88 |
|
|
#define __int3264 __int64
|
89 |
|
|
|
90 |
|
|
#else
|
91 |
|
|
typedef _W64 int INT_PTR, *PINT_PTR;
|
92 |
|
|
typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
|
93 |
|
|
|
94 |
|
|
typedef _W64 long LONG_PTR, *PLONG_PTR;
|
95 |
|
|
typedef _W64 unsigned long ULONG_PTR, *PULONG_PTR;
|
96 |
|
|
|
97 |
|
|
#define __int3264 __int32
|
98 |
|
|
|
99 |
|
|
#endif
|
100 |
|
|
#endif // midl64
|
101 |
|
|
|
102 |
|
|
//
|
103 |
|
|
// HALF_PTR is half the size of a pointer it intended for use with
|
104 |
|
|
// within strcuture which contain a pointer and two small fields.
|
105 |
|
|
// UHALF_PTR is the unsigned variation.
|
106 |
|
|
//
|
107 |
|
|
|
108 |
|
|
#ifdef _WIN64
|
109 |
|
|
|
110 |
|
|
#define ADDRESS_TAG_BIT 0x40000000000UI64
|
111 |
|
|
|
112 |
|
|
typedef unsigned __int64 HANDLE_PTR;
|
113 |
|
|
typedef unsigned int UHALF_PTR, *PUHALF_PTR;
|
114 |
|
|
typedef int HALF_PTR, *PHALF_PTR;
|
115 |
|
|
|
116 |
|
|
#pragma warning(disable:4311) // type cast truncation
|
117 |
|
|
#if _MSC_VER >= 1200
|
118 |
|
|
#pragma warning(push)
|
119 |
|
|
#endif
|
120 |
|
|
#pragma warning(disable:4305) // type cast truncation
|
121 |
|
|
|
122 |
|
|
#if !defined(__midl)
|
123 |
|
|
__inline
|
124 |
|
|
unsigned long
|
125 |
|
|
HandleToULong(
|
126 |
|
|
const void *h
|
127 |
|
|
)
|
128 |
|
|
{
|
129 |
|
|
return((unsigned long) h );
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
__inline
|
133 |
|
|
long
|
134 |
|
|
HandleToLong(
|
135 |
|
|
const void *h
|
136 |
|
|
)
|
137 |
|
|
{
|
138 |
|
|
return((long) h );
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
__inline
|
142 |
|
|
void *
|
143 |
|
|
ULongToHandle(
|
144 |
|
|
const unsigned long h
|
145 |
|
|
)
|
146 |
|
|
{
|
147 |
|
|
return((void *) (UINT_PTR) h );
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
__inline
|
152 |
|
|
void *
|
153 |
|
|
LongToHandle(
|
154 |
|
|
const long h
|
155 |
|
|
)
|
156 |
|
|
{
|
157 |
|
|
return((void *) (INT_PTR) h );
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
__inline
|
162 |
|
|
unsigned long
|
163 |
|
|
PtrToUlong(
|
164 |
|
|
const void *p
|
165 |
|
|
)
|
166 |
|
|
{
|
167 |
|
|
return((unsigned long) p );
|
168 |
|
|
}
|
169 |
|
|
|
170 |
|
|
__inline
|
171 |
|
|
unsigned int
|
172 |
|
|
PtrToUint(
|
173 |
|
|
const void *p
|
174 |
|
|
)
|
175 |
|
|
{
|
176 |
|
|
return((unsigned int) p );
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
__inline
|
180 |
|
|
unsigned short
|
181 |
|
|
PtrToUshort(
|
182 |
|
|
const void *p
|
183 |
|
|
)
|
184 |
|
|
{
|
185 |
|
|
return((unsigned short) p );
|
186 |
|
|
}
|
187 |
|
|
|
188 |
|
|
__inline
|
189 |
|
|
long
|
190 |
|
|
PtrToLong(
|
191 |
|
|
const void *p
|
192 |
|
|
)
|
193 |
|
|
{
|
194 |
|
|
return((long) p );
|
195 |
|
|
}
|
196 |
|
|
|
197 |
|
|
__inline
|
198 |
|
|
int
|
199 |
|
|
PtrToInt(
|
200 |
|
|
const void *p
|
201 |
|
|
)
|
202 |
|
|
{
|
203 |
|
|
return((int) p );
|
204 |
|
|
}
|
205 |
|
|
|
206 |
|
|
__inline
|
207 |
|
|
short
|
208 |
|
|
PtrToShort(
|
209 |
|
|
const void *p
|
210 |
|
|
)
|
211 |
|
|
{
|
212 |
|
|
return((short) p );
|
213 |
|
|
}
|
214 |
|
|
|
215 |
|
|
__inline
|
216 |
|
|
void *
|
217 |
|
|
IntToPtr(
|
218 |
|
|
const int i
|
219 |
|
|
)
|
220 |
|
|
// Caution: IntToPtr() sign-extends the int value.
|
221 |
|
|
{
|
222 |
|
|
return( (void *)(INT_PTR)i );
|
223 |
|
|
}
|
224 |
|
|
|
225 |
|
|
__inline
|
226 |
|
|
void *
|
227 |
|
|
UIntToPtr(
|
228 |
|
|
const unsigned int ui
|
229 |
|
|
)
|
230 |
|
|
// Caution: UIntToPtr() zero-extends the unsigned int value.
|
231 |
|
|
{
|
232 |
|
|
return( (void *)(UINT_PTR)ui );
|
233 |
|
|
}
|
234 |
|
|
|
235 |
|
|
__inline
|
236 |
|
|
void *
|
237 |
|
|
LongToPtr(
|
238 |
|
|
const long l
|
239 |
|
|
)
|
240 |
|
|
// Caution: LongToPtr() sign-extends the long value.
|
241 |
|
|
{
|
242 |
|
|
return( (void *)(LONG_PTR)l );
|
243 |
|
|
}
|
244 |
|
|
|
245 |
|
|
__inline
|
246 |
|
|
void *
|
247 |
|
|
ULongToPtr(
|
248 |
|
|
const unsigned long ul
|
249 |
|
|
)
|
250 |
|
|
// Caution: ULongToPtr() zero-extends the unsigned long value.
|
251 |
|
|
{
|
252 |
|
|
return( (void *)(ULONG_PTR)ul );
|
253 |
|
|
}
|
254 |
|
|
|
255 |
|
|
#endif // !_midl
|
256 |
|
|
#if _MSC_VER >= 1200
|
257 |
|
|
#pragma warning(pop) // restore 4305
|
258 |
|
|
#endif
|
259 |
|
|
#pragma warning(3:4311) // bump 4311 to a level 3
|
260 |
|
|
|
261 |
|
|
#else // !_WIN64
|
262 |
|
|
|
263 |
|
|
#define ADDRESS_TAG_BIT 0x80000000UL
|
264 |
|
|
|
265 |
|
|
typedef unsigned short UHALF_PTR, *PUHALF_PTR;
|
266 |
|
|
typedef short HALF_PTR, *PHALF_PTR;
|
267 |
|
|
typedef _W64 unsigned long HANDLE_PTR;
|
268 |
|
|
|
269 |
|
|
#define HandleToULong( h ) ((ULONG)(ULONG_PTR)(h) )
|
270 |
|
|
#define HandleToLong( h ) ((LONG)(LONG_PTR) (h) )
|
271 |
|
|
#define ULongToHandle( ul ) ((HANDLE)(ULONG_PTR) (ul) )
|
272 |
|
|
#define LongToHandle( h ) ((HANDLE)(LONG_PTR) (h) )
|
273 |
|
|
#define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) )
|
274 |
|
|
#define PtrToLong( p ) ((LONG)(LONG_PTR) (p) )
|
275 |
|
|
#define PtrToUint( p ) ((UINT)(UINT_PTR) (p) )
|
276 |
|
|
#define PtrToInt( p ) ((INT)(INT_PTR) (p) )
|
277 |
|
|
#define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) )
|
278 |
|
|
#define PtrToShort( p ) ((short)(LONG_PTR)(p) )
|
279 |
|
|
#define IntToPtr( i ) ((VOID *)(INT_PTR)((int)i))
|
280 |
|
|
#define UIntToPtr( ui ) ((VOID *)(UINT_PTR)((unsigned int)ui))
|
281 |
|
|
#define LongToPtr( l ) ((VOID *)(LONG_PTR)((long)l))
|
282 |
|
|
#define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)ul))
|
283 |
|
|
|
284 |
|
|
#endif // !_WIN64
|
285 |
|
|
|
286 |
|
|
#define HandleToUlong(h) HandleToULong(h)
|
287 |
|
|
#define UlongToHandle(ul) ULongToHandle(ul)
|
288 |
|
|
#define UlongToPtr(ul) ULongToPtr(ul)
|
289 |
|
|
#define UintToPtr(ui) UIntToPtr(ui)
|
290 |
|
|
|
291 |
|
|
#define MAXUINT_PTR (~((UINT_PTR)0))
|
292 |
|
|
#define MAXINT_PTR ((INT_PTR)(MAXUINT_PTR >> 1))
|
293 |
|
|
#define MININT_PTR (~MAXINT_PTR)
|
294 |
|
|
|
295 |
|
|
#define MAXULONG_PTR (~((ULONG_PTR)0))
|
296 |
|
|
#define MAXLONG_PTR ((LONG_PTR)(MAXULONG_PTR >> 1))
|
297 |
|
|
#define MINLONG_PTR (~MAXLONG_PTR)
|
298 |
|
|
|
299 |
|
|
#define MAXUHALF_PTR ((UHALF_PTR)~0)
|
300 |
|
|
#define MAXHALF_PTR ((HALF_PTR)(MAXUHALF_PTR >> 1))
|
301 |
|
|
#define MINHALF_PTR (~MAXHALF_PTR)
|
302 |
|
|
|
303 |
|
|
//
|
304 |
|
|
// SIZE_T used for counts or ranges which need to span the range of
|
305 |
|
|
// of a pointer. SSIZE_T is the signed variation.
|
306 |
|
|
//
|
307 |
|
|
|
308 |
|
|
typedef ULONG_PTR SIZE_T, *PSIZE_T;
|
309 |
|
|
typedef LONG_PTR SSIZE_T, *PSSIZE_T;
|
310 |
|
|
|
311 |
|
|
//
|
312 |
|
|
// Add Windows flavor DWORD_PTR types
|
313 |
|
|
//
|
314 |
|
|
|
315 |
|
|
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
|
316 |
|
|
|
317 |
|
|
//
|
318 |
|
|
// The following types are guaranteed to be signed and 64 bits wide.
|
319 |
|
|
//
|
320 |
|
|
|
321 |
|
|
typedef __int64 LONG64, *PLONG64;
|
322 |
|
|
|
323 |
|
|
|
324 |
|
|
//
|
325 |
|
|
// The following types are guaranteed to be unsigned and 64 bits wide.
|
326 |
|
|
//
|
327 |
|
|
|
328 |
|
|
typedef unsigned __int64 ULONG64, *PULONG64;
|
329 |
|
|
typedef unsigned __int64 DWORD64, *PDWORD64;
|
330 |
|
|
|
331 |
|
|
//
|
332 |
|
|
// Thread affinity.
|
333 |
|
|
//
|
334 |
|
|
|
335 |
|
|
typedef ULONG_PTR KAFFINITY;
|
336 |
|
|
typedef KAFFINITY *PKAFFINITY;
|
337 |
|
|
|
338 |
|
|
#ifdef __cplusplus
|
339 |
|
|
}
|
340 |
|
|
#endif
|
341 |
|
|
|
342 |
|
|
#endif // _BASETSD_H_
|