1 /***********************************************************************\
2 *                               basetsd.d                               *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *             Translated from MinGW API for MS-Windows 3.12             *
7 *                           by Stewart Gordon                           *
8 *                                                                       *
9 *                       Placed into public domain                       *
10 \***********************************************************************/
11 module win32.basetsd;
12 
13 /*	This template is used in these modules to declare constant pointer types,
14  *	in order to support both D 1.x and 2.x.
15  */
16 template CPtr(T) {
17 	version (D_Version2) {
18 		// must use mixin so that it doesn't cause a syntax error under D1
19 		mixin("alias const(T)* CPtr;");
20 	} else {
21 		alias T* CPtr;
22 	}
23 }
24 
25 // [SnakE 2009-02-23] Moved HANDLE definition here from winnt.d to avoid
26 // 'forwatd template reference' to CPtr from winnt.d caused by a circular
27 // import.
28 
29 alias void* HANDLE;
30 
31 alias HANDLE* PHANDLE, LPHANDLE;
32 
33 version (Win64) {
34 	alias long __int3264;
35 	const ulong ADDRESS_TAG_BIT = 0x40000000000;
36 
37 	alias long INT_PTR, LONG_PTR;
38 	alias long* PINT_PTR, PLONG_PTR;
39 	alias ulong UINT_PTR, ULONG_PTR, HANDLE_PTR;
40 	alias ulong* PUINT_PTR, PULONG_PTR;
41 	alias int HALF_PTR;
42 	alias int* PHALF_PTR;
43 	alias uint UHALF_PTR;
44 	alias uint* PUHALF_PTR;
45 
46 	/*	*To* functions are conditioned out in MinGW.
47 	 *	Presumably they're not working/tested yet.  Comment:
48 			TODO when WIN64 is here
49 	 */
50 } else {
51 	alias int __int3264;
52 	const uint ADDRESS_TAG_BIT = 0x80000000;
53 
54 	alias int INT_PTR, LONG_PTR;
55 	alias int* PINT_PTR, PLONG_PTR;
56 	alias uint UINT_PTR, ULONG_PTR, HANDLE_PTR;
57 	alias uint* PUINT_PTR, PULONG_PTR;
58 	alias short HALF_PTR;
59 	alias short* PHALF_PTR;
60 	alias ushort UHALF_PTR;
61 	alias ushort* PUHALF_PTR;
62 
63 	uint HandleToUlong(HANDLE h)      { return cast(uint) h; }
64 	int HandleToLong(HANDLE h)        { return cast(int) h; }
65 	HANDLE LongToHandle(LONG_PTR h)   { return cast(HANDLE) h; }
66 	uint PtrToUlong(CPtr!(void) p)    { return cast(uint) p; }
67 	uint PtrToUint(CPtr!(void) p)     { return cast(uint) p; }
68 	int PtrToInt(CPtr!(void) p)       { return cast(int) p; }
69 	ushort PtrToUshort(CPtr!(void) p) { return cast(ushort) p; }
70 	short PtrToShort(CPtr!(void) p)   { return cast(short) p; }
71 	void* IntToPtr(int i)             { return cast(void*) i; }
72 	void* UIntToPtr(uint ui)          { return cast(void*) ui; }
73 	alias IntToPtr LongToPtr;
74 	alias UIntToPtr ULongToPtr;
75 }
76 
77 alias UIntToPtr UintToPtr, UlongToPtr;
78 
79 enum : UINT_PTR {
80 	MAXUINT_PTR = UINT_PTR.max
81 }
82 
83 enum : INT_PTR {
84 	MAXINT_PTR = INT_PTR.max,
85 	MININT_PTR = INT_PTR.min
86 }
87 
88 enum : ULONG_PTR {
89 	MAXULONG_PTR = ULONG_PTR.max
90 }
91 
92 enum : LONG_PTR {
93 	MAXLONG_PTR = LONG_PTR.max,
94 	MINLONG_PTR = LONG_PTR.min
95 }
96 
97 enum : UHALF_PTR {
98 	MAXUHALF_PTR = UHALF_PTR.max
99 }
100 
101 enum : HALF_PTR {
102 	MAXHALF_PTR = HALF_PTR.max,
103 	MINHALF_PTR = HALF_PTR.min
104 }
105 
106 alias byte INT8;
107 alias byte* PINT8;
108 alias ubyte UINT8;
109 alias ubyte* PUINT8;
110 
111 alias short INT16;
112 alias short* PINT16;
113 alias ushort UINT16;
114 alias ushort* PUINT16;
115 
116 alias int LONG32, INT32;
117 alias int* PLONG32, PINT32;
118 alias uint ULONG32, DWORD32, UINT32;
119 alias uint* PULONG32, PDWORD32, PUINT32;
120 
121 alias ULONG_PTR SIZE_T, DWORD_PTR;
122 alias ULONG_PTR* PSIZE_T, PDWORD_PTR;
123 alias LONG_PTR SSIZE_T;
124 alias LONG_PTR* PSSIZE_T;
125 
126 alias long LONG64, INT64;
127 alias long* PLONG64, PINT64;
128 alias ulong ULONG64, DWORD64, UINT64;
129 alias ulong* PULONG64, PDWORD64, PUINT64;