Differences From Artifact [2d9ec241e2f4195d]:
- File
src/win32/basetsd.d
- 2015-04-21 10:46:55 - part of checkin [4e2933c620] on branch trunk - Rebased to the latest verson dmd 2.067. Not yet verified the outcome. (user: kinaba) [annotate]
To Artifact [386a11e840358068]:
- File
src/win32/basetsd.d
-
2015-05-05 06:49:05
- part of checkin
[9b639cf2d6]
on branch trunk
- Working version for update to 2.067.
The problem was __gshared. Replacing it with TLS fixed the issue. Remaining problem is that "hack.d"'s CloseHandle hack is not working anymore.
(user: kinaba) [annotate]
-
2015-05-05 06:49:05
- part of checkin
[9b639cf2d6]
on branch trunk
- Working version for update to 2.067.
8 * * 8 * *
9 * Placed into public domain * 9 * Placed into public domain *
10 \***********************************************************************/ 10 \***********************************************************************/
11 module win32.basetsd; 11 module win32.basetsd;
12 12
13 /* This template is used in these modules to declare constant pointer types 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. 14 * in order to support both D 1.x and 2.x.
> 15 * Since removed - now supporting only D2
15 */ 16 */
16 template CPtr(T) { | 17 /*template CPtr(T) {
17 version (D_Version2) { 18 version (D_Version2) {
18 // must use mixin so that it doesn't cause a syntax error under 19 // must use mixin so that it doesn't cause a syntax error under
19 mixin("alias const(T)* CPtr;"); 20 mixin("alias const(T)* CPtr;");
20 } else { 21 } else {
21 alias T* CPtr; 22 alias T* CPtr;
22 } 23 }
> 24 }*/
> 25
> 26 /* [CyberShadow VP 2011.12.22] typedef is now deprecated in D2.
> 27 */
> 28 template TypeDef(T) {
> 29 version (D_Version2) {
> 30 alias T TypeDef;
> 31 } else {
> 32 // must use mixin so that it doesn't cause a deprecation error u
> 33 mixin("typedef T TypeDef;");
> 34 }
23 } 35 }
24 36
25 // [SnakE 2009-02-23] Moved HANDLE definition here from winnt.d to avoid 37 // [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 38 // 'forwatd template reference' to CPtr from winnt.d caused by a circular
27 // import. 39 // import.
28 40
> 41 alias TypeDef!(void*) HANDLE;
29 alias void* HANDLE; | 42 /+struct HANDLE {
> 43 const(void)* h;
> 44 alias h this;
> 45 }+/
30 46
> 47 package template DECLARE_HANDLE(string name, base = HANDLE) {
> 48 mixin ("alias " ~ base.stringof ~ " " ~ name ~ ";");
> 49 }
31 alias HANDLE* PHANDLE, LPHANDLE; 50 alias HANDLE* PHANDLE, LPHANDLE;
32 51
33 version (Win64) { 52 version (Win64) {
34 alias long __int3264; 53 alias long __int3264;
35 const ulong ADDRESS_TAG_BIT = 0x40000000000; 54 const ulong ADDRESS_TAG_BIT = 0x40000000000;
36 55
37 alias long INT_PTR, LONG_PTR; 56 alias long INT_PTR, LONG_PTR;
................................................................................................................................................................................
39 alias ulong UINT_PTR, ULONG_PTR, HANDLE_PTR; 58 alias ulong UINT_PTR, ULONG_PTR, HANDLE_PTR;
40 alias ulong* PUINT_PTR, PULONG_PTR; 59 alias ulong* PUINT_PTR, PULONG_PTR;
41 alias int HALF_PTR; 60 alias int HALF_PTR;
42 alias int* PHALF_PTR; 61 alias int* PHALF_PTR;
43 alias uint UHALF_PTR; 62 alias uint UHALF_PTR;
44 alias uint* PUHALF_PTR; 63 alias uint* PUHALF_PTR;
45 64
46 /* *To* functions are conditioned out in MinGW. | 65 uint HandleToULong(void* h) { return(cast(uint) cast(ULONG_PTR) h); }
47 * Presumably they're not working/tested yet. Comment: | 66 int HandleToLong(void* h) { return(cast(int) cast(LONG_PTR) h); }
48 TODO when WIN64 is here | 67 void* ULongToHandle(uint h) { return(cast(void*) cast(UINT_PTR) h); }
49 */ | 68 void* LongToHandle(int h) { return(cast(void*) cast(INT_PTR) h); }
> 69 uint PtrToUlong(void* p) { return(cast(uint) cast(ULONG_PTR) p); }
> 70 uint PtrToUint(void* p) { return(cast(uint) cast(UINT_PTR) p); }
> 71 ushort PtrToUshort(void* p) { return(cast(ushort) cast(uint) cast(ULONG_
> 72 int PtrToLong(void* p) { return(cast(int) cast(LONG_PTR) p); }
> 73 int PtrToInt(void* p) { return(cast(int) cast(INT_PTR) p); }
> 74 short PtrToShort(void* p) { return(cast(short) cast(int) cast(LONG_PTR
> 75 void* IntToPtr(int i) { return(cast(void*) cast(INT_PTR) i); }
> 76 void* UIntToPtr(uint ui) { return(cast(void*) cast(UINT_PTR) ui); }
> 77 void* LongToPtr(int l) { return(cast(void*) cast(LONG_PTR) l); }
> 78 void* ULongToPtr(uint ul) { return(cast(void*) cast(ULONG_PTR) ul); }
> 79
50 } else { 80 } else {
51 alias int __int3264; 81 alias int __int3264;
52 const uint ADDRESS_TAG_BIT = 0x80000000; 82 const uint ADDRESS_TAG_BIT = 0x80000000;
53 83
54 alias int INT_PTR, LONG_PTR; 84 alias int INT_PTR, LONG_PTR;
55 alias int* PINT_PTR, PLONG_PTR; 85 alias int* PINT_PTR, PLONG_PTR;
56 alias uint UINT_PTR, ULONG_PTR, HANDLE_PTR; 86 alias uint UINT_PTR, ULONG_PTR, HANDLE_PTR;
................................................................................................................................................................................
58 alias short HALF_PTR; 88 alias short HALF_PTR;
59 alias short* PHALF_PTR; 89 alias short* PHALF_PTR;
60 alias ushort UHALF_PTR; 90 alias ushort UHALF_PTR;
61 alias ushort* PUHALF_PTR; 91 alias ushort* PUHALF_PTR;
62 92
63 uint HandleToUlong(HANDLE h) { return cast(uint) h; } 93 uint HandleToUlong(HANDLE h) { return cast(uint) h; }
64 int HandleToLong(HANDLE h) { return cast(int) h; } 94 int HandleToLong(HANDLE h) { return cast(int) h; }
65 HANDLE LongToHandle(LONG_PTR h) { return cast(HANDLE) h; } | 95 HANDLE LongToHandle(LONG_PTR h) { return cast(HANDLE)h; }
66 uint PtrToUlong(CPtr!(void) p) { return cast(uint) p; } | 96 uint PtrToUlong(const(void)* p) { return cast(uint) p; }
67 uint PtrToUint(CPtr!(void) p) { return cast(uint) p; } | 97 uint PtrToUint(const(void)* p) { return cast(uint) p; }
68 int PtrToInt(CPtr!(void) p) { return cast(int) p; } | 98 int PtrToInt(const(void)* p) { return cast(int) p; }
69 ushort PtrToUshort(CPtr!(void) p) { return cast(ushort) p; } | 99 ushort PtrToUshort(const(void)* p) { return cast(ushort) p; }
70 short PtrToShort(CPtr!(void) p) { return cast(short) p; } | 100 short PtrToShort(const(void)* p) { return cast(short) p; }
71 void* IntToPtr(int i) { return cast(void*) i; } 101 void* IntToPtr(int i) { return cast(void*) i; }
72 void* UIntToPtr(uint ui) { return cast(void*) ui; } 102 void* UIntToPtr(uint ui) { return cast(void*) ui; }
73 alias IntToPtr LongToPtr; 103 alias IntToPtr LongToPtr;
74 alias UIntToPtr ULongToPtr; 104 alias UIntToPtr ULongToPtr;
75 } 105 }
76 106
77 alias UIntToPtr UintToPtr, UlongToPtr; 107 alias UIntToPtr UintToPtr, UlongToPtr;