[PSDK]
[reactos.git] / reactos / include / psdk / basetsd.h
1 #ifndef _BASETSD_H
2 #define _BASETSD_H
3
4 #ifndef _M_AMD64
5 #if !defined(__ROS_LONG64__)
6 #ifdef __WINESRC__
7 #define __ROS_LONG64__
8 #endif
9 #endif
10 #endif
11
12 #ifdef __GNUC__
13 #ifndef __int64
14 #define __int64 long long
15 #endif
16 #endif
17
18 #if defined(_MSC_VER) && (_MSC_VER < 1300)
19 #error Old MSVC compiler version.
20 #endif
21
22 #ifdef _MAC
23 #error Not supported.
24 #endif
25
26 #if !defined(MIDL_PASS) && !defined(RC_INVOKED)
27 #define POINTER_64 __ptr64
28 #if defined(_WIN64)
29 #define POINTER_32 __ptr32
30 #else
31 #define POINTER_32
32 #endif
33 #else
34 #define POINTER_64
35 #define POINTER_32
36 #endif /* !defined(MIDL_PASS) && !defined(RC_INVOKED) */
37
38 #if defined(_M_MRX000) || defined(_M_AMD64) || defined(_M_IA64)
39 typedef unsigned __int64 POINTER_64_INT;
40 #else
41 typedef unsigned long POINTER_64_INT;
42 #endif
43
44 #if defined(_WIN64)
45 #define __int3264 __int64
46 #define ADDRESS_TAG_BIT 0x40000000000UI64
47 #else /* !_WIN64 */
48 #define __int3264 __int32
49 #define ADDRESS_TAG_BIT 0x80000000UL
50 #define HandleToUlong( h ) ((ULONG)(ULONG_PTR)(h) )
51 #define HandleToLong( h ) ((LONG)(LONG_PTR) (h) )
52 #define ULongToHandle( h) ((HANDLE)(ULONG_PTR) (h))
53 #define LongToHandle( h) ((HANDLE)(LONG_PTR) (h))
54 #define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) )
55 #define PtrToLong( p ) ((LONG)(LONG_PTR) (p) )
56 #define PtrToUint( p ) ((UINT)(UINT_PTR) (p) )
57 #define PtrToInt( p ) ((INT)(INT_PTR) (p) )
58 #define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) )
59 #define PtrToShort( p ) ((short)(LONG_PTR)(p) )
60 #define IntToPtr( i ) ((VOID*)(INT_PTR)((int)i))
61 #define UIntToPtr( ui ) ((VOID*)(UINT_PTR)((unsigned int)ui))
62 #define LongToPtr( l ) ((VOID*)(LONG_PTR)((long)l))
63 #define ULongToPtr( ul ) ((VOID*)(ULONG_PTR)((unsigned long)ul))
64 #endif /* !_WIN64 */
65
66 #define UlongToHandle(ul) ULongToHandle(ul)
67 #define UlongToPtr(ul) ULongToPtr(ul)
68 #define UintToPtr(ui) UIntToPtr(ui)
69 #define MAXUINT_PTR (~((UINT_PTR)0))
70 #define MAXINT_PTR ((INT_PTR)(MAXUINT_PTR >> 1))
71 #define MININT_PTR (~MAXINT_PTR)
72 #define MAXULONG_PTR (~((ULONG_PTR)0))
73 #define MAXLONG_PTR ((LONG_PTR)(MAXULONG_PTR >> 1))
74 #define MINLONG_PTR (~MAXLONG_PTR)
75 #define MAXUHALF_PTR ((UHALF_PTR)~0)
76 #define MAXHALF_PTR ((HALF_PTR)(MAXUHALF_PTR >> 1))
77 #define MINHALF_PTR (~MAXHALF_PTR)
78
79 #if _WIN32_WINNT >= 0x0600
80
81 #define MAXUINT ((UINT)~((UINT)0))
82 #define MAXULONGLONG ((ULONGLONG)~((ULONGLONG)0))
83
84 #endif
85
86 #ifndef RC_INVOKED
87 #ifdef __cplusplus
88 extern "C" {
89 #endif
90 typedef int LONG32, *PLONG32;
91 #ifndef XFree86Server
92 typedef int INT32, *PINT32;
93 #endif /* ndef XFree86Server */
94 typedef unsigned int ULONG32, *PULONG32;
95 typedef unsigned int DWORD32, *PDWORD32;
96 typedef unsigned int UINT32, *PUINT32;
97
98 #if defined(_WIN64)
99 typedef __int64 INT_PTR, *PINT_PTR;
100 typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
101 typedef __int64 LONG_PTR, *PLONG_PTR;
102 typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
103 typedef unsigned __int64 HANDLE_PTR;
104 typedef unsigned int UHALF_PTR, *PUHALF_PTR;
105 typedef int HALF_PTR, *PHALF_PTR;
106
107 #if !defined(__midl) && !defined(__WIDL__)
108 static inline unsigned long HandleToUlong(const void* h )
109 { return((unsigned long)(ULONG_PTR) h ); }
110 static inline long HandleToLong( const void* h )
111 { return((long)(LONG_PTR) h ); }
112 static inline void* ULongToHandle( const long h )
113 { return((void*) (UINT_PTR) h ); }
114 static inline void* LongToHandle( const long h )
115 { return((void*) (INT_PTR) h ); }
116 static inline unsigned long PtrToUlong( const void* p)
117 { return((unsigned long)(ULONG_PTR) p ); }
118 static inline unsigned int PtrToUint( const void* p )
119 { return((unsigned int)(UINT_PTR) p ); }
120 static inline unsigned short PtrToUshort( const void* p )
121 { return((unsigned short)(ULONG_PTR) p ); }
122 static inline long PtrToLong( const void* p )
123 { return((long)(LONG_PTR) p ); }
124 static inline int PtrToInt( const void* p )
125 { return((int)(INT_PTR) p ); }
126 static inline short PtrToShort( const void* p )
127 { return((short)(INT_PTR) p ); }
128 static inline void* IntToPtr( const int i )
129 { return( (void*)(INT_PTR)i ); }
130 static inline void* UIntToPtr(const unsigned int ui)
131 { return( (void*)(UINT_PTR)ui ); }
132 static inline void* LongToPtr( const long l )
133 { return( (void*)(LONG_PTR)l ); }
134 static inline void* ULongToPtr( const unsigned long ul )
135 { return( (void*)(ULONG_PTR)ul ); }
136 #endif /* !__midl */
137 #else /* !_WIN64 */
138 #if !defined(__ROS_LONG64__)
139 typedef int INT_PTR, *PINT_PTR;
140 typedef unsigned int UINT_PTR, *PUINT_PTR;
141 #else
142 typedef long INT_PTR, *PINT_PTR;
143 typedef unsigned long UINT_PTR, *PUINT_PTR;
144 #endif
145
146 #ifndef LONG_PTR_DEFINED
147 #define LONG_PTR_DEFINED
148 typedef long LONG_PTR, *PLONG_PTR;
149 typedef unsigned long ULONG_PTR, *PULONG_PTR;
150 #endif
151
152 typedef unsigned short UHALF_PTR, *PUHALF_PTR;
153 typedef short HALF_PTR, *PHALF_PTR;
154
155 #ifndef HANDLE_PTR_DEFINED
156 #define HANDLE_PTR_DEFINED
157 typedef unsigned long HANDLE_PTR;
158 #endif
159
160 #endif /* !_WIN64 */
161
162 typedef ULONG_PTR SIZE_T, *PSIZE_T;
163 typedef LONG_PTR SSIZE_T, *PSSIZE_T;
164 typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
165 typedef __int64 LONG64, *PLONG64;
166 typedef __int64 INT64, *PINT64;
167 typedef unsigned __int64 ULONG64, *PULONG64;
168 typedef unsigned __int64 DWORD64, *PDWORD64;
169 typedef unsigned __int64 UINT64, *PUINT64;
170
171 typedef signed char INT8, *PINT8;
172 typedef unsigned char UINT8, *PUINT8;
173 typedef signed short INT16, *PINT16;
174 typedef unsigned short UINT16, *PUINT16;
175
176 typedef ULONG_PTR KAFFINITY;
177 typedef KAFFINITY *PKAFFINITY;
178
179 #ifdef __cplusplus
180 }
181 #endif
182 #endif /* !RC_INVOKED */
183
184 #endif /* _BASETSD_H */