Sync to trunk head (r42241)
[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 #ifndef RC_INVOKED
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 typedef int LONG32, *PLONG32;
58 #ifndef XFree86Server
59 typedef int INT32, *PINT32;
60 #endif /* ndef XFree86Server */
61 typedef unsigned int ULONG32, *PULONG32;
62 typedef unsigned int DWORD32, *PDWORD32;
63 typedef unsigned int UINT32, *PUINT32;
64
65 #if defined(_WIN64)
66 typedef __int64 INT_PTR, *PINT_PTR;
67 typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
68 typedef __int64 LONG_PTR, *PLONG_PTR;
69 typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
70 typedef unsigned __int64 HANDLE_PTR;
71 typedef unsigned int UHALF_PTR, *PUHALF_PTR;
72 typedef int HALF_PTR, *PHALF_PTR;
73
74 #if !defined(__midl) && !defined(__WIDL__)
75 static inline unsigned long HandleToUlong(const void* h )
76 { return((unsigned long)(ULONG_PTR) h ); }
77 static inline long HandleToLong( const void* h )
78 { return((long)(LONG_PTR) h ); }
79 static inline void* ULongToHandle( const long h )
80 { return((void*) (UINT_PTR) h ); }
81 static inline void* LongToHandle( const long h )
82 { return((void*) (INT_PTR) h ); }
83 static inline unsigned long PtrToUlong( const void* p)
84 { return((unsigned long)(ULONG_PTR) p ); }
85 static inline unsigned int PtrToUint( const void* p )
86 { return((unsigned int)(UINT_PTR) p ); }
87 static inline unsigned short PtrToUshort( const void* p )
88 { return((unsigned short)(ULONG_PTR) p ); }
89 static inline long PtrToLong( const void* p )
90 { return((long)(LONG_PTR) p ); }
91 static inline int PtrToInt( const void* p )
92 { return((int)(INT_PTR) p ); }
93 static inline short PtrToShort( const void* p )
94 { return((short)(INT_PTR) p ); }
95 static inline void* IntToPtr( const int i )
96 { return( (void*)(INT_PTR)i ); }
97 static inline void* UIntToPtr(const unsigned int ui)
98 { return( (void*)(UINT_PTR)ui ); }
99 static inline void* LongToPtr( const long l )
100 { return( (void*)(LONG_PTR)l ); }
101 static inline void* ULongToPtr( const unsigned long ul )
102 { return( (void*)(ULONG_PTR)ul ); }
103 #endif /* !__midl */
104 #else /* !_WIN64 */
105 #if !defined(__ROS_LONG64__)
106 typedef int INT_PTR, *PINT_PTR;
107 typedef unsigned int UINT_PTR, *PUINT_PTR;
108 #else
109 typedef long INT_PTR, *PINT_PTR;
110 typedef unsigned long UINT_PTR, *PUINT_PTR;
111 #endif
112
113 #ifndef LONG_PTR_DEFINED
114 #define LONG_PTR_DEFINED
115 typedef long LONG_PTR, *PLONG_PTR;
116 typedef unsigned long ULONG_PTR, *PULONG_PTR;
117 #endif
118
119 typedef unsigned short UHALF_PTR, *PUHALF_PTR;
120 typedef short HALF_PTR, *PHALF_PTR;
121
122 #ifndef HANDLE_PTR_DEFINED
123 #define HANDLE_PTR_DEFINED
124 typedef unsigned long HANDLE_PTR;
125 #endif
126
127 #endif /* !_WIN64 */
128
129 typedef ULONG_PTR SIZE_T, *PSIZE_T;
130 typedef LONG_PTR SSIZE_T, *PSSIZE_T;
131 typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
132 typedef __int64 LONG64, *PLONG64;
133 typedef __int64 INT64, *PINT64;
134 typedef unsigned __int64 ULONG64, *PULONG64;
135 typedef unsigned __int64 DWORD64, *PDWORD64;
136 typedef unsigned __int64 UINT64, *PUINT64;
137
138 typedef signed char INT8, *PINT8;
139 typedef unsigned char UINT8, *PUINT8;
140 typedef signed short INT16, *PINT16;
141 typedef unsigned short UINT16, *PUINT16;
142
143 typedef ULONG_PTR KAFFINITY;
144 typedef KAFFINITY *PKAFFINITY;
145
146 #ifdef __cplusplus
147 }
148 #endif
149 #endif /* !RC_INVOKED */
150
151 #endif /* _BASETSD_H */