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