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