Of course, I forgot to commit the new file in revision 22049...
[reactos.git] / reactos / include / basetsd.h
1 #ifndef _BASETSD_H
2 #define _BASETSD_H
3 #if __GNUC__ >=3
4 #pragma GCC system_header
5 #endif
6
7 #ifndef _W64
8 #if defined(_MSC_VER) && !defined(MIDL_PASS) && _MSC_VER >= 1300
9 #define _W64 __w64
10 #else
11 #define _W64
12 #endif
13 #endif
14
15 #ifdef __GNUC__
16 #ifndef __int64
17 #define __int64 long long
18 #endif
19 #endif
20
21 #if defined(_WIN64)
22 #define __int3264 __int64
23 #define ADDRESS_TAG_BIT 0x40000000000UI64
24 #else /* !_WIN64 */
25 #define __int3264 __int32
26 #define ADDRESS_TAG_BIT 0x80000000UL
27 #define HandleToUlong( h ) ((ULONG)(ULONG_PTR)(h) )
28 #define HandleToLong( h ) ((LONG)(LONG_PTR) (h) )
29 #define LongToHandle( h) ((HANDLE)(LONG_PTR) (h))
30 #define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) )
31 #define PtrToLong( p ) ((LONG)(LONG_PTR) (p) )
32 #define PtrToUint( p ) ((UINT)(UINT_PTR) (p) )
33 #define PtrToInt( p ) ((INT)(INT_PTR) (p) )
34 #define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) )
35 #define PtrToShort( p ) ((short)(LONG_PTR)(p) )
36 #define IntToPtr( i ) ((VOID*)(INT_PTR)((int)i))
37 #define UIntToPtr( ui ) ((VOID*)(UINT_PTR)((unsigned int)ui))
38 #define LongToPtr( l ) ((VOID*)(LONG_PTR)((long)l))
39 #define ULongToPtr( ul ) ((VOID*)(ULONG_PTR)((unsigned long)ul))
40 #endif /* !_WIN64 */
41
42 #define UlongToPtr(ul) ULongToPtr(ul)
43 #define UintToPtr(ui) UIntToPtr(ui)
44 #define MAXUINT_PTR (~((UINT_PTR)0))
45 #define MAXINT_PTR ((INT_PTR)(MAXUINT_PTR >> 1))
46 #define MININT_PTR (~MAXINT_PTR)
47 #define MAXULONG_PTR (~((ULONG_PTR)0))
48 #define MAXLONG_PTR ((LONG_PTR)(MAXULONG_PTR >> 1))
49 #define MINLONG_PTR (~MAXLONG_PTR)
50 #define MAXUHALF_PTR ((UHALF_PTR)~0)
51 #define MAXHALF_PTR ((HALF_PTR)(MAXUHALF_PTR >> 1))
52 #define MINHALF_PTR (~MAXHALF_PTR)
53
54 #ifndef RC_INVOKED
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 typedef int LONG32, *PLONG32;
59 #ifndef XFree86Server
60 typedef int INT32, *PINT32;
61 #endif /* ndef XFree86Server */
62 typedef unsigned int ULONG32, *PULONG32;
63 typedef unsigned int DWORD32, *PDWORD32;
64 typedef unsigned int UINT32, *PUINT32;
65
66 #if defined(_WIN64)
67 typedef _W64 __int64 INT_PTR, *PINT_PTR;
68 typedef _W64 unsigned __int64 UINT_PTR, *PUINT_PTR;
69 typedef _W64 __int64 LONG_PTR, *PLONG_PTR;
70 typedef _W64 unsigned __int64 ULONG_PTR, *PULONG_PTR;
71 typedef _W64 unsigned __int64 HANDLE_PTR;
72 typedef unsigned int UHALF_PTR, *PUHALF_PTR;
73 typedef int HALF_PTR, *PHALF_PTR;
74
75 #if 0 /* TODO when WIN64 is here */
76 inline unsigned long HandleToUlong(const void* h )
77 { return((unsigned long) h ); }
78 inline long HandleToLong( const void* h )
79 { return((long) h ); }
80 inline void* LongToHandle( const long h )
81 { return((void*) (INT_PTR) h ); }
82 inline unsigned long PtrToUlong( const void* p)
83 { return((unsigned long) p ); }
84 inline unsigned int PtrToUint( const void* p )
85 { return((unsigned int) p ); }
86 inline unsigned short PtrToUshort( const void* p )
87 { return((unsigned short) p ); }
88 inline long PtrToLong( const void* p )
89 { return((long) p ); }
90 inline int PtrToInt( const void* p )
91 { return((int) p ); }
92 inline short PtrToShort( const void* p )
93 { return((short) p ); }
94 inline void* IntToPtr( const int i )
95 { return( (void*)(INT_PTR)i ); }
96 inline void* UIntToPtr(const unsigned int ui)
97 { return( (void*)(UINT_PTR)ui ); }
98 inline void* LongToPtr( const long l )
99 { return( (void*)(LONG_PTR)l ); }
100 inline void* ULongToPtr( const unsigned long ul )
101 { return( (void*)(ULONG_PTR)ul ); }
102 #endif /* 0_ */
103
104 #else /* !_WIN64 */
105 typedef _W64 int INT_PTR, *PINT_PTR;
106 typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
107 typedef _W64 long LONG_PTR, *PLONG_PTR;
108 typedef _W64 unsigned long ULONG_PTR, *PULONG_PTR;
109 typedef unsigned short UHALF_PTR, *PUHALF_PTR;
110 typedef short HALF_PTR, *PHALF_PTR;
111 typedef _W64 unsigned long HANDLE_PTR;
112 #endif /* !_WIN64 */
113
114 typedef _W64 ULONG_PTR SIZE_T, *PSIZE_T;
115 typedef _W64 LONG_PTR SSIZE_T, *PSSIZE_T;
116 typedef _W64 ULONG_PTR DWORD_PTR, *PDWORD_PTR;
117 typedef __int64 LONG64, *PLONG64;
118 typedef __int64 INT64, *PINT64;
119 typedef unsigned __int64 ULONG64, *PULONG64;
120 typedef unsigned __int64 DWORD64, *PDWORD64;
121 typedef unsigned __int64 UINT64, *PUINT64;
122
123 typedef signed short INT16, *PINT16;
124 typedef unsigned short UINT16, *PUINT16;
125
126 typedef ULONG_PTR KAFFINITY;
127 typedef KAFFINITY *PKAFFINITY;
128
129 #ifdef __cplusplus
130 }
131 #endif
132 #endif /* !RC_INVOKED */
133
134 #endif /* _BASETSD_H */