e2e5b93f453f24fbf354fa2dc23a3d6759efd6ec
[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(_WIN64)
19 #define __int3264 __int64
20 #define ADDRESS_TAG_BIT 0x40000000000UI64
21 #else /* !_WIN64 */
22 #define __int3264 __int32
23 #define ADDRESS_TAG_BIT 0x80000000UL
24 #define HandleToUlong( h ) ((ULONG)(ULONG_PTR)(h) )
25 #define HandleToLong( h ) ((LONG)(LONG_PTR) (h) )
26 #define ULongToHandle( h) ((HANDLE)(ULONG_PTR) (h))
27 #define LongToHandle( h) ((HANDLE)(LONG_PTR) (h))
28 #define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) )
29 #define PtrToLong( p ) ((LONG)(LONG_PTR) (p) )
30 #define PtrToUint( p ) ((UINT)(UINT_PTR) (p) )
31 #define PtrToInt( p ) ((INT)(INT_PTR) (p) )
32 #define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) )
33 #define PtrToShort( p ) ((short)(LONG_PTR)(p) )
34 #define IntToPtr( i ) ((VOID*)(INT_PTR)((int)i))
35 #define UIntToPtr( ui ) ((VOID*)(UINT_PTR)((unsigned int)ui))
36 #define LongToPtr( l ) ((VOID*)(LONG_PTR)((long)l))
37 #define ULongToPtr( ul ) ((VOID*)(ULONG_PTR)((unsigned long)ul))
38 #endif /* !_WIN64 */
39
40 #define UlongToHandle(ul) ULongToHandle(ul)
41 #define UlongToPtr(ul) ULongToPtr(ul)
42 #define UintToPtr(ui) UIntToPtr(ui)
43 #define MAXUINT_PTR (~((UINT_PTR)0))
44 #define MAXINT_PTR ((INT_PTR)(MAXUINT_PTR >> 1))
45 #define MININT_PTR (~MAXINT_PTR)
46 #define MAXULONG_PTR (~((ULONG_PTR)0))
47 #define MAXLONG_PTR ((LONG_PTR)(MAXULONG_PTR >> 1))
48 #define MINLONG_PTR (~MAXLONG_PTR)
49 #define MAXUHALF_PTR ((UHALF_PTR)~0)
50 #define MAXHALF_PTR ((HALF_PTR)(MAXUHALF_PTR >> 1))
51 #define MINHALF_PTR (~MAXHALF_PTR)
52
53 #if _WIN32_WINNT >= 0x0600
54
55 #define MAXUINT ((UINT)~((UINT)0))
56 #define MAXULONGLONG ((ULONGLONG)~((ULONGLONG)0))
57
58 #endif
59
60 #ifndef RC_INVOKED
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 typedef int LONG32, *PLONG32;
65 #ifndef XFree86Server
66 typedef int INT32, *PINT32;
67 #endif /* ndef XFree86Server */
68 typedef unsigned int ULONG32, *PULONG32;
69 typedef unsigned int DWORD32, *PDWORD32;
70 typedef unsigned int UINT32, *PUINT32;
71
72 #if defined(_WIN64)
73 typedef __int64 INT_PTR, *PINT_PTR;
74 typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
75 typedef __int64 LONG_PTR, *PLONG_PTR;
76 typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
77 typedef unsigned __int64 HANDLE_PTR;
78 typedef unsigned int UHALF_PTR, *PUHALF_PTR;
79 typedef int HALF_PTR, *PHALF_PTR;
80
81 #if !defined(__midl) && !defined(__WIDL__)
82 static inline unsigned long HandleToUlong(const void* h )
83 { return((unsigned long)(ULONG_PTR) h ); }
84 static inline long HandleToLong( const void* h )
85 { return((long)(LONG_PTR) h ); }
86 static inline void* ULongToHandle( const long h )
87 { return((void*) (UINT_PTR) h ); }
88 static inline void* LongToHandle( const long h )
89 { return((void*) (INT_PTR) h ); }
90 static inline unsigned long PtrToUlong( const void* p)
91 { return((unsigned long)(ULONG_PTR) p ); }
92 static inline unsigned int PtrToUint( const void* p )
93 { return((unsigned int)(UINT_PTR) p ); }
94 static inline unsigned short PtrToUshort( const void* p )
95 { return((unsigned short)(ULONG_PTR) p ); }
96 static inline long PtrToLong( const void* p )
97 { return((long)(LONG_PTR) p ); }
98 static inline int PtrToInt( const void* p )
99 { return((int)(INT_PTR) p ); }
100 static inline short PtrToShort( const void* p )
101 { return((short)(INT_PTR) p ); }
102 static inline void* IntToPtr( const int i )
103 { return( (void*)(INT_PTR)i ); }
104 static inline void* UIntToPtr(const unsigned int ui)
105 { return( (void*)(UINT_PTR)ui ); }
106 static inline void* LongToPtr( const long l )
107 { return( (void*)(LONG_PTR)l ); }
108 static inline void* ULongToPtr( const unsigned long ul )
109 { return( (void*)(ULONG_PTR)ul ); }
110 #endif /* !__midl */
111 #else /* !_WIN64 */
112 #if !defined(__ROS_LONG64__)
113 typedef int INT_PTR, *PINT_PTR;
114 typedef unsigned int UINT_PTR, *PUINT_PTR;
115 #else
116 typedef long INT_PTR, *PINT_PTR;
117 typedef unsigned long UINT_PTR, *PUINT_PTR;
118 #endif
119
120 #ifndef LONG_PTR_DEFINED
121 #define LONG_PTR_DEFINED
122 typedef long LONG_PTR, *PLONG_PTR;
123 typedef unsigned long ULONG_PTR, *PULONG_PTR;
124 #endif
125
126 typedef unsigned short UHALF_PTR, *PUHALF_PTR;
127 typedef short HALF_PTR, *PHALF_PTR;
128
129 #ifndef HANDLE_PTR_DEFINED
130 #define HANDLE_PTR_DEFINED
131 typedef unsigned long HANDLE_PTR;
132 #endif
133
134 #endif /* !_WIN64 */
135
136 typedef ULONG_PTR SIZE_T, *PSIZE_T;
137 typedef LONG_PTR SSIZE_T, *PSSIZE_T;
138 typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
139 typedef __int64 LONG64, *PLONG64;
140 typedef __int64 INT64, *PINT64;
141 typedef unsigned __int64 ULONG64, *PULONG64;
142 typedef unsigned __int64 DWORD64, *PDWORD64;
143 typedef unsigned __int64 UINT64, *PUINT64;
144
145 typedef signed char INT8, *PINT8;
146 typedef unsigned char UINT8, *PUINT8;
147 typedef signed short INT16, *PINT16;
148 typedef unsigned short UINT16, *PUINT16;
149
150 typedef ULONG_PTR KAFFINITY;
151 typedef KAFFINITY *PKAFFINITY;
152
153 #ifdef __cplusplus
154 }
155 #endif
156 #endif /* !RC_INVOKED */
157
158 #endif /* _BASETSD_H */