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