Skip to content

Commit 49b3800

Browse files
authored
resolve compilation & codegen issues on delphi posix compilers (#68)
1 parent 29f3ad9 commit 49b3800

3 files changed

Lines changed: 25 additions & 7 deletions

File tree

HashLib/src/Crypto/Blake2BParams/HlpBlake2BParams.pas

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ TBlake2BTreeConfig = class sealed(TInterfacedObject, IBlake2BTreeConfig)
9797
procedure ValidateInnerHashSize(AInnerHashSize: Byte); inline;
9898
procedure ValidateMaxDepth(AMaxDepth: Byte); inline;
9999
procedure ValidateNodeDepth(ANodeDepth: Byte); inline;
100-
procedure ValidateNodeOffset(ANodeOffset: UInt64); inline;
100+
procedure ValidateNodeOffset(ANodeOffset: UInt64);
101101

102102
function GetFanOut: Byte; inline;
103103
procedure SetFanOut(AValue: Byte); inline;
@@ -342,9 +342,10 @@ procedure TBlake2BTreeConfig.ValidateNodeDepth(ANodeDepth: Byte);
342342
end;
343343

344344
procedure TBlake2BTreeConfig.ValidateNodeOffset(ANodeOffset: UInt64);
345+
const
346+
MaxNodeOffset: UInt64 = $FFFFFFFFFFFFFFFF; // (2^64) - 1
345347
begin
346-
// ANodeOffset > ((2^64) - 1)
347-
if ANodeOffset > System.High(UInt64) then
348+
if ANodeOffset > MaxNodeOffset then
348349
begin
349350
raise EArgumentInvalidHashLibException.CreateRes
350351
(@SInvalidNodeOffsetParameter);

HashLib/src/Include/HashLib.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
{$MESSAGE ERROR 'This Library requires Delphi 2010 or higher.'}
2222
{$IFEND}
2323

24+
// Silence H2586 (legacy $IFEND) on XE4+ where $ENDIF can also close $IF.
25+
// The $LEGACYIFEND directive itself was introduced in XE4 (25.0), so the
26+
// guard is necessary to keep Delphi 2010 / XE / XE2 / XE3 compiling.
27+
{$IF CompilerVersion >= 25.0}
28+
{$LEGACYIFEND ON}
29+
{$IFEND}
30+
2431
{$DEFINE DELPHI}
2532

2633
{$DEFINITIONINFO ON} // Enable code browsing (Ctrl+Click)

HashLib/src/Utils/HlpArmHwCapProvider.pas

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,17 @@ implementation
139139

140140
class procedure TArmHwCapProvider.ResolveDynamicImports();
141141
var
142-
LHandle: Pointer;
142+
LHandle: NativeUInt;
143143
begin
144144
FGetAuxVal := nil;
145145

146+
{$IFDEF FPC}
147+
LHandle := NativeUInt(dlopen(nil, RTLD_NOW));
148+
{$ELSE}
146149
LHandle := dlopen(nil, RTLD_NOW);
147-
if LHandle = nil then
150+
{$ENDIF}
151+
152+
if LHandle = 0 then
148153
Exit;
149154

150155
try
@@ -179,12 +184,17 @@ class function TArmHwCapProvider.GetHwCap2(): UInt64;
179184

180185
class procedure TArmHwCapProvider.ResolveDynamicImports();
181186
var
182-
LHandle: Pointer;
187+
LHandle: NativeUInt;
183188
begin
184189
FElfAuxInfo := nil;
185190

191+
{$IFDEF FPC}
192+
LHandle := NativeUInt(dlopen(nil, RTLD_NOW));
193+
{$ELSE}
186194
LHandle := dlopen(nil, RTLD_NOW);
187-
if LHandle = nil then
195+
{$ENDIF}
196+
197+
if LHandle = 0 then
188198
Exit;
189199

190200
try

0 commit comments

Comments
 (0)