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