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