VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/i8042prt/include/basetsd.h@ 11938

Last change on this file since 11938 was 1, checked in by vboxsync, 55 years ago

import

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette