9bafa25e4e39855ae8884849593663a96ad48690
[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(_X86_) && !defined(_AMD64_) && !defined(_IA64_) && !defined(_ALPHA_) && \
27 !defined(_ARM_) && !defined(_PPC_) && !defined(_MIPS_) && !defined(_68K_)
28
29 #if defined(_M_AMD64) || defined(__x86_64__)
30 #define _AMD64_
31 #elif defined(_M_IX86) || defined(__i386__)
32 #define _X86_
33 #elif defined(_M_IA64) || defined(__ia64__)
34 #define _IA64_
35 #elif defined(_M_ALPHA) || defined(__alpha__)
36 #define _ALPHA_
37 #elif defined(_M_ARM) || defined(__arm__)
38 #define _ARM_
39 #elif defined(_M_PPC) || defined(__powerpc__)
40 #define _PPC_
41 #elif defined(_M_MRX000) || defined(__mips__)
42 #define _MIPS_
43 #elif defined(_M_M68K) || defined(__68k__)
44 #define _68K_
45 #endif
46
47 #endif
48
49 #if !defined(MIDL_PASS) && !defined(RC_INVOKED)
50 #define POINTER_64 __ptr64
51 #if defined(_WIN64)
52 #define POINTER_32 __ptr32
53 #else
54 #define POINTER_32
55 #endif
56 #else
57 #define POINTER_64
58 #define POINTER_32
59 #endif /* !defined(MIDL_PASS) && !defined(RC_INVOKED) */
60
61 #if defined(_M_MRX000) || defined(_M_AMD64) || defined(_M_IA64)
62 typedef unsigned __int64 POINTER_64_INT;
63 #else
64 typedef unsigned long POINTER_64_INT;
65 #endif
66
67 #if 0 /* Not supported yet */
68 #define POINTER_SIGNED __sptr
69 #define POINTER_UNSIGNED __uptr
70 #else
71 #define POINTER_SIGNED
72 #define POINTER_UNSIGNED
73 #endif
74
75 #define SPOINTER_32 POINTER_SIGNED POINTER_32
76 #define UPOINTER_32 POINTER_UNSIGNED POINTER_32
77
78 #if defined(_WIN64)
79 #define __int3264 __int64
80 typedef __int64 SHANDLE_PTR;
81 typedef unsigned __int64 HANDLE_PTR;
82 typedef unsigned int UHALF_PTR, *PUHALF_PTR;
83 typedef int HALF_PTR, *PHALF_PTR;
84 #define ADDRESS_TAG_BIT 0x40000000000UI64
85 #else /* !_WIN64 */
86 #define __int3264 __int32
87 #define ADDRESS_TAG_BIT 0x80000000UL
88 typedef unsigned short UHALF_PTR, *PUHALF_PTR;
89 typedef short HALF_PTR, *PHALF_PTR;
90 typedef long SHANDLE_PTR;
91 typedef unsigned long HANDLE_PTR;
92 #define HandleToUlong( h ) ((ULONG)(ULONG_PTR)(h) )
93 #define HandleToLong( h ) ((LONG)(LONG_PTR) (h) )
94 #define ULongToHandle( h) ((HANDLE)(ULONG_PTR) (h))
95 #define LongToHandle( h) ((HANDLE)(LONG_PTR) (h))
96 #define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) )
97 #define PtrToLong( p ) ((LONG)(LONG_PTR) (p) )
98 #define PtrToUint( p ) ((UINT)(UINT_PTR) (p) )
99 #define PtrToInt( p ) ((INT)(INT_PTR) (p) )
100 #define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) )
101 #define PtrToShort( p ) ((short)(LONG_PTR)(p) )
102 #define IntToPtr( i ) ((VOID*)(INT_PTR)((int)i))
103 #define UIntToPtr( ui ) ((VOID*)(UINT_PTR)((unsigned int)ui))
104 #define LongToPtr( l ) ((VOID*)(LONG_PTR)((long)l))
105 #define ULongToPtr( ul ) ((VOID*)(ULONG_PTR)((unsigned long)ul))
106 #endif /* !_WIN64 */
107
108 #define HandleToULong(h) HandleToUlong(h)
109
110 #define UlongToHandle(ul) ULongToHandle(ul)
111 #define UlongToPtr(ul) ULongToPtr(ul)
112 #define UintToPtr(ui) UIntToPtr(ui)
113 #define MAXUINT_PTR (~((UINT_PTR)0))
114 #define MAXINT_PTR ((INT_PTR)(MAXUINT_PTR >> 1))
115 #define MININT_PTR (~MAXINT_PTR)
116 #define MAXULONG_PTR (~((ULONG_PTR)0))
117 #define MAXLONG_PTR ((LONG_PTR)(MAXULONG_PTR >> 1))
118 #define MINLONG_PTR (~MAXLONG_PTR)
119 #define MAXUHALF_PTR ((UHALF_PTR)~0)
120 #define MAXHALF_PTR ((HALF_PTR)(MAXUHALF_PTR >> 1))
121 #define MINHALF_PTR (~MAXHALF_PTR)
122
123 #if _WIN32_WINNT >= 0x0600
124
125 #define MAXUINT ((UINT)~((UINT)0))
126 #define MAXULONGLONG ((ULONGLONG)~((ULONGLONG)0))
127
128 #endif
129
130 #ifndef RC_INVOKED
131 #ifdef __cplusplus
132 extern "C" {
133 #endif
134 typedef int LONG32, *PLONG32;
135 #ifndef XFree86Server
136 typedef int INT32, *PINT32;
137 #endif /* ndef XFree86Server */
138 typedef unsigned int ULONG32, *PULONG32;
139 typedef unsigned int DWORD32, *PDWORD32;
140 typedef unsigned int UINT32, *PUINT32;
141
142 #if defined(_WIN64)
143 typedef __int64 INT_PTR, *PINT_PTR;
144 typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
145 typedef __int64 LONG_PTR, *PLONG_PTR;
146 typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
147
148 #if !defined(__midl) && !defined(__WIDL__)
149 static inline unsigned long HandleToUlong(const void* h )
150 { return((unsigned long)(ULONG_PTR) h ); }
151 static inline long HandleToLong( const void* h )
152 { return((long)(LONG_PTR) h ); }
153 static inline void* ULongToHandle( const long h )
154 { return((void*) (UINT_PTR) h ); }
155 static inline void* LongToHandle( const long h )
156 { return((void*) (INT_PTR) h ); }
157 static inline unsigned long PtrToUlong( const void* p)
158 { return((unsigned long)(ULONG_PTR) p ); }
159 static inline unsigned int PtrToUint( const void* p )
160 { return((unsigned int)(UINT_PTR) p ); }
161 static inline unsigned short PtrToUshort( const void* p )
162 { return((unsigned short)(ULONG_PTR) p ); }
163 static inline long PtrToLong( const void* p )
164 { return((long)(LONG_PTR) p ); }
165 static inline int PtrToInt( const void* p )
166 { return((int)(INT_PTR) p ); }
167 static inline short PtrToShort( const void* p )
168 { return((short)(INT_PTR) p ); }
169 static inline void* IntToPtr( const int i )
170 { return( (void*)(INT_PTR)i ); }
171 static inline void* UIntToPtr(const unsigned int ui)
172 { return( (void*)(UINT_PTR)ui ); }
173 static inline void* LongToPtr( const long l )
174 { return( (void*)(LONG_PTR)l ); }
175 static inline void* ULongToPtr( const unsigned long ul )
176 { return( (void*)(ULONG_PTR)ul ); }
177 #endif /* !__midl */
178 #else /* !_WIN64 */
179 #if !defined(__ROS_LONG64__)
180 typedef int INT_PTR, *PINT_PTR;
181 typedef unsigned int UINT_PTR, *PUINT_PTR;
182 #else
183 typedef long INT_PTR, *PINT_PTR;
184 typedef unsigned long UINT_PTR, *PUINT_PTR;
185 #endif
186
187 #ifndef LONG_PTR_DEFINED
188 #define LONG_PTR_DEFINED
189 typedef long LONG_PTR, *PLONG_PTR;
190 typedef unsigned long ULONG_PTR, *PULONG_PTR;
191 #endif
192
193 #endif /* !_WIN64 */
194
195 typedef ULONG_PTR SIZE_T, *PSIZE_T;
196 typedef LONG_PTR SSIZE_T, *PSSIZE_T;
197 typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
198 typedef __int64 LONG64, *PLONG64;
199 typedef __int64 INT64, *PINT64;
200 typedef unsigned __int64 ULONG64, *PULONG64;
201 typedef unsigned __int64 DWORD64, *PDWORD64;
202 typedef unsigned __int64 UINT64, *PUINT64;
203
204 typedef signed char INT8, *PINT8;
205 typedef unsigned char UINT8, *PUINT8;
206 typedef signed short INT16, *PINT16;
207 typedef unsigned short UINT16, *PUINT16;
208
209 typedef ULONG_PTR KAFFINITY;
210 typedef KAFFINITY *PKAFFINITY;
211
212 #ifdef __cplusplus
213 }
214 #endif
215 #endif /* !RC_INVOKED */
216
217 #endif /* _BASETSD_H */