forked from edwinyzh/Delphi-64-bit-compiler-RTL-speed-up_2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
D64TBB.pas
86 lines (69 loc) · 1.88 KB
/
D64TBB.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
unit D64TBB;
// Intel Threading Building Block Scalable Allocator
// 22 Febr 2019 Roberto Della Pasqua www.dellapasqua.com
// 24 March 2021 updated to latest stable version branch
interface
{$IFDEF WIN64}
uses D64IPP;
{$ENDIF}
implementation
{$IFDEF WIN64}
const
DMalloc = 'D64TBB.DLL';
{$ENDIF}
{$IFDEF WIN32}
const
DMalloc = 'D32TBB.DLL';
{$ENDIF}
function D64Malloc(Size: NativeUint): Pointer; cdecl; external DMalloc name 'scalable_malloc';
procedure D64Freemem(P: Pointer); cdecl; external DMalloc name 'scalable_free';
function D64Realloc(P: Pointer; Size: NativeUint): Pointer; cdecl; external DMalloc name 'scalable_realloc';
function RDPGetMem(Size: Nativeint): Pointer; inline;
begin
Result := D64Malloc(Size);
end;
function RDPFreeMem(P: Pointer): Integer; inline;
begin
D64Freemem(P);
Result := 0;
end;
function RDPReallocMem(P: Pointer; Size: Nativeint): Pointer; inline;
begin
Result := D64Realloc(P, Size);
end;
function RDPAllocMem(Size: Nativeint): Pointer; inline;
begin
Result := D64Malloc(Size);
if (Result <> nil) then
{$IFDEF WIN64}
DZero(Result, Size);
{$ENDIF}
{$IFDEF WIN32}
FillChar(Result^, Size, 0);
{$ENDIF}
end;
function QRegisterExpectedMemoryLeak(P: Pointer): Boolean; inline;
begin
Result := False;
end;
function QUnregisterExpectedMemoryLeak(P: Pointer): Boolean; inline;
begin
Result := False;
end;
const
RDPMemoryManager: TMemoryManagerEx = (
Getmem: RDPGetMem;
Freemem: RDPFreeMem;
Reallocmem: RDPReallocMem;
Allocmem: RDPAllocMem;
RegisterExpectedMemoryLeak: QRegisterExpectedMemoryLeak;
UnregisterExpectedMemoryLeak: QRegisterExpectedMemoryLeak
);
var
OldMemoryManager: TMemoryManagerEx;
initialization
GetMemoryManager(OldMemoryManager);
SetMemoryManager(RDPMemoryManager);
finalization
SetMemoryManager(OldMemoryManager);
end.