- add a hack to basetsd.h to undefine _X86_ on amd64 builds (gcc defines it)
[reactos.git] / reactos / include / psdk / basetsd.h
1 #ifndef _BASETSD_H
2 #define _BASETSD_H
3 #if __GNUC__ >=3
4 #pragma GCC system_header
5 #endif
6
7 #ifdef __GNUC__
8 #ifndef __int64
9 #define __int64 long long
10 #endif
11 #if defined(_M_AMD64) || defined(__x86_64__)
12 #if defined(_X86_)
13 #undef _X86_
14 #endif
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 UlongToPtr(ul) ULongToPtr(ul)
41 #define UintToPtr(ui) UIntToPtr(ui)
42 #define MAXUINT_PTR (~((UINT_PTR)0))
43 #define MAXINT_PTR ((INT_PTR)(MAXUINT_PTR >> 1))
44 #define MININT_PTR (~MAXINT_PTR)
45 #define MAXULONG_PTR (~((ULONG_PTR)0))
46 #define MAXLONG_PTR ((LONG_PTR)(MAXULONG_PTR >> 1))
47 #define MINLONG_PTR (~MAXLONG_PTR)
48 #define MAXUHALF_PTR ((UHALF_PTR)~0)
49 #define MAXHALF_PTR ((HALF_PTR)(MAXUHALF_PTR >> 1))
50 #define MINHALF_PTR (~MAXHALF_PTR)
51
52 #ifndef RC_INVOKED
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 typedef int LONG32, *PLONG32;
57 #ifndef XFree86Server
58 typedef int INT32, *PINT32;
59 #endif /* ndef XFree86Server */
60 typedef unsigned int ULONG32, *PULONG32;
61 typedef unsigned int DWORD32, *PDWORD32;
62 typedef unsigned int UINT32, *PUINT32;
63
64 #if defined(_WIN64)
65 typedef __int64 INT_PTR, *PINT_PTR;
66 typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
67 typedef __int64 LONG_PTR, *PLONG_PTR;
68 typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
69 typedef unsigned __int64 HANDLE_PTR;
70 typedef unsigned int UHALF_PTR, *PUHALF_PTR;
71 typedef int HALF_PTR, *PHALF_PTR;
72
73 #if !defined(__midl) && !defined(__WIDL__)
74 static inline unsigned long HandleToUlong(const void* h )
75 { return((unsigned long)(ULONG_PTR) h ); }
76 static inline long HandleToLong( const void* h )
77 { return((long)(LONG_PTR) h ); }
78 static inline void* ULongToHandle( const long h )
79 { return((void*) (UINT_PTR) h ); }
80 static inline void* LongToHandle( const long h )
81 { return((void*) (INT_PTR) h ); }
82 static inline unsigned long PtrToUlong( const void* p)
83 { return((unsigned long)(ULONG_PTR) p ); }
84 static inline unsigned int PtrToUint( const void* p )
85 { return((unsigned int)(UINT_PTR) p ); }
86 static inline unsigned short PtrToUshort( const void* p )
87 { return((unsigned short)(ULONG_PTR) p ); }
88 static inline long PtrToLong( const void* p )
89 { return((long)(LONG_PTR) p ); }
90 static inline int PtrToInt( const void* p )
91 { return((int)(INT_PTR) p ); }
92 static inline short PtrToShort( const void* p )
93 { return((short)(INT_PTR) p ); }
94 static inline void* IntToPtr( const int i )
95 { return( (void*)(INT_PTR)i ); }
96 static inline void* UIntToPtr(const unsigned int ui)
97 { return( (void*)(UINT_PTR)ui ); }
98 static inline void* LongToPtr( const long l )
99 { return( (void*)(LONG_PTR)l ); }
100 static inline void* ULongToPtr( const unsigned long ul )
101 { return( (void*)(ULONG_PTR)ul ); }
102 #endif /* !__midl */
103 #else /* !_WIN64 */
104 typedef int INT_PTR, *PINT_PTR;
105 typedef unsigned int UINT_PTR, *PUINT_PTR;
106
107 #ifndef LONG_PTR_DEFINED
108 #define LONG_PTR_DEFINED
109 typedef long LONG_PTR, *PLONG_PTR;
110 typedef unsigned long ULONG_PTR, *PULONG_PTR;
111 #endif
112
113 typedef unsigned short UHALF_PTR, *PUHALF_PTR;
114 typedef short HALF_PTR, *PHALF_PTR;
115
116 #ifndef HANDLE_PTR_DEFINED
117 #define HANDLE_PTR_DEFINED
118 typedef unsigned long HANDLE_PTR;
119 #endif
120
121 #endif /* !_WIN64 */
122
123 typedef ULONG_PTR SIZE_T, *PSIZE_T;
124 typedef LONG_PTR SSIZE_T, *PSSIZE_T;
125 typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
126 typedef __int64 LONG64, *PLONG64;
127 typedef __int64 INT64, *PINT64;
128 typedef unsigned __int64 ULONG64, *PULONG64;
129 typedef unsigned __int64 DWORD64, *PDWORD64;
130 typedef unsigned __int64 UINT64, *PUINT64;
131
132 typedef signed short INT16, *PINT16;
133 typedef unsigned short UINT16, *PUINT16;
134
135 typedef ULONG_PTR KAFFINITY;
136 typedef KAFFINITY *PKAFFINITY;
137
138 #ifdef __cplusplus
139 }
140 #endif
141 #endif /* !RC_INVOKED */
142
143 #endif /* _BASETSD_H */