Merge trunk head (r43756)
[reactos.git] / reactos / include / psdk / basetsd.h
index dc90e67..e2e5b93 100644 (file)
@@ -1,14 +1,11 @@
 #ifndef _BASETSD_H
 #define _BASETSD_H
-#if __GNUC__ >=3
-#pragma GCC system_header
-#endif
 
-#ifndef _W64
-#if defined(_MSC_VER) && !defined(MIDL_PASS) && _MSC_VER >= 1300
-#define _W64 __w64
-#else
-#define _W64
+#ifndef _M_AMD64
+#if !defined(__ROS_LONG64__)
+#ifdef __WINESRC__
+#define __ROS_LONG64__
+#endif
 #endif
 #endif
 
@@ -26,6 +23,7 @@
 #define ADDRESS_TAG_BIT 0x80000000UL
 #define HandleToUlong( h ) ((ULONG)(ULONG_PTR)(h) )
 #define HandleToLong( h ) ((LONG)(LONG_PTR) (h) )
+#define ULongToHandle( h) ((HANDLE)(ULONG_PTR) (h))
 #define LongToHandle( h) ((HANDLE)(LONG_PTR) (h))
 #define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) )
 #define PtrToLong( p ) ((LONG)(LONG_PTR) (p) )
@@ -39,6 +37,7 @@
 #define ULongToPtr( ul )  ((VOID*)(ULONG_PTR)((unsigned long)ul))
 #endif /* !_WIN64 */
 
+#define UlongToHandle(ul) ULongToHandle(ul)
 #define UlongToPtr(ul) ULongToPtr(ul)
 #define UintToPtr(ui) UIntToPtr(ui)
 #define MAXUINT_PTR  (~((UINT_PTR)0))
 #define MAXHALF_PTR  ((HALF_PTR)(MAXUHALF_PTR >> 1))
 #define MINHALF_PTR  (~MAXHALF_PTR)
 
+#if _WIN32_WINNT >= 0x0600
+
+#define MAXUINT      ((UINT)~((UINT)0))
+#define MAXULONGLONG ((ULONGLONG)~((ULONGLONG)0))
+
+#endif
+
 #ifndef RC_INVOKED
 #ifdef __cplusplus
 extern "C" {
@@ -64,62 +70,80 @@ typedef unsigned int DWORD32, *PDWORD32;
 typedef unsigned int UINT32, *PUINT32;
 
 #if defined(_WIN64)
-typedef _W64 __int64 INT_PTR, *PINT_PTR;
-typedef _W64 unsigned __int64 UINT_PTR, *PUINT_PTR;
-typedef _W64 __int64 LONG_PTR, *PLONG_PTR;
-typedef _W64 unsigned __int64 ULONG_PTR, *PULONG_PTR;
-typedef _W64 unsigned __int64 HANDLE_PTR;
+typedef __int64 INT_PTR, *PINT_PTR;
+typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
+typedef __int64 LONG_PTR, *PLONG_PTR;
+typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
+typedef unsigned __int64 HANDLE_PTR;
 typedef unsigned int UHALF_PTR, *PUHALF_PTR;
 typedef int HALF_PTR, *PHALF_PTR;
 
-#if 0 /* TODO when WIN64 is here */
-inline unsigned long HandleToUlong(const void* h )
-    { return((unsigned long) h ); }
-inline long HandleToLong( const void* h )
-    { return((long) h ); }
-inline void* LongToHandle( const long h )
+#if !defined(__midl) && !defined(__WIDL__)
+static inline unsigned long HandleToUlong(const void* h )
+    { return((unsigned long)(ULONG_PTR) h ); }
+static inline long HandleToLong( const void* h )
+    { return((long)(LONG_PTR) h ); }
+static inline void* ULongToHandle( const long h )
+    { return((void*) (UINT_PTR) h ); }
+static inline void* LongToHandle( const long h )
     { return((void*) (INT_PTR) h ); }
-inline unsigned long PtrToUlong( const void* p)
-    { return((unsigned long) p ); }
-inline unsigned int PtrToUint( const void* p )
-    { return((unsigned int) p ); }
-inline unsigned short PtrToUshort( const void* p )
-    { return((unsigned short) p ); }
-inline long PtrToLong( const void* p )
-    { return((long) p ); }
-inline int PtrToInt( const void* p )
-    { return((int) p ); }
-inline short PtrToShort( const void* p )
-    { return((short) p ); }
-inline void* IntToPtr( const int i )
+static inline unsigned long PtrToUlong( const void* p)
+    { return((unsigned long)(ULONG_PTR) p ); }
+static inline unsigned int PtrToUint( const void* p )
+    { return((unsigned int)(UINT_PTR) p ); }
+static inline unsigned short PtrToUshort( const void* p )
+    { return((unsigned short)(ULONG_PTR) p ); }
+static inline long PtrToLong( const void* p )
+    { return((long)(LONG_PTR) p ); }
+static inline int PtrToInt( const void* p )
+    { return((int)(INT_PTR) p ); }
+static inline short PtrToShort( const void* p )
+    { return((short)(INT_PTR) p ); }
+static inline void* IntToPtr( const int i )
     { return( (void*)(INT_PTR)i ); }
-inline void* UIntToPtr(const unsigned int ui)
+static inline void* UIntToPtr(const unsigned int ui)
     { return( (void*)(UINT_PTR)ui ); }
-inline void* LongToPtr( const long l )
+static inline void* LongToPtr( const long l )
     { return( (void*)(LONG_PTR)l ); }
-inline void* ULongToPtr( const unsigned long ul )
+static inline void* ULongToPtr( const unsigned long ul )
     { return( (void*)(ULONG_PTR)ul ); }
-#endif /* 0_ */
-
+#endif /* !__midl */
 #else /*  !_WIN64 */
-typedef _W64 int INT_PTR, *PINT_PTR;
-typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
-typedef _W64 long LONG_PTR, *PLONG_PTR;
-typedef _W64 unsigned long ULONG_PTR, *PULONG_PTR;
+#if !defined(__ROS_LONG64__)
+typedef int INT_PTR, *PINT_PTR;
+typedef unsigned int UINT_PTR, *PUINT_PTR;
+#else
+typedef long INT_PTR, *PINT_PTR;
+typedef unsigned long UINT_PTR, *PUINT_PTR;
+#endif
+
+#ifndef LONG_PTR_DEFINED
+#define LONG_PTR_DEFINED
+       typedef long LONG_PTR, *PLONG_PTR;
+       typedef unsigned long ULONG_PTR, *PULONG_PTR;
+#endif
+
 typedef unsigned short UHALF_PTR, *PUHALF_PTR;
 typedef short HALF_PTR, *PHALF_PTR;
-typedef _W64 unsigned long HANDLE_PTR;
+
+#ifndef HANDLE_PTR_DEFINED
+#define HANDLE_PTR_DEFINED
+       typedef unsigned long HANDLE_PTR;
+#endif
+
 #endif /* !_WIN64 */
 
-typedef _W64 ULONG_PTR SIZE_T, *PSIZE_T;
-typedef _W64 LONG_PTR SSIZE_T, *PSSIZE_T;
-typedef _W64 ULONG_PTR DWORD_PTR, *PDWORD_PTR;
+typedef ULONG_PTR SIZE_T, *PSIZE_T;
+typedef LONG_PTR SSIZE_T, *PSSIZE_T;
+typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
 typedef __int64 LONG64, *PLONG64;
 typedef __int64 INT64,  *PINT64;
 typedef unsigned __int64 ULONG64, *PULONG64;
 typedef unsigned __int64 DWORD64, *PDWORD64;
 typedef unsigned __int64 UINT64,  *PUINT64;
 
+typedef signed char INT8, *PINT8;
+typedef unsigned char UINT8, *PUINT8;
 typedef signed short INT16, *PINT16;
 typedef unsigned short UINT16, *PUINT16;