From 42b0015157be2d493a6965e664763e0642116af4 Mon Sep 17 00:00:00 2001 From: Ugochukwu Mmaduekwe Date: Sat, 2 May 2026 20:47:36 +0100 Subject: [PATCH 1/2] fix delphi posix compilation --- HashLib/src/Include/HashLib.inc | 7 +++++++ HashLib/src/Utils/HlpArmHwCapProvider.pas | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/HashLib/src/Include/HashLib.inc b/HashLib/src/Include/HashLib.inc index 6c47f0b..d0a32d1 100644 --- a/HashLib/src/Include/HashLib.inc +++ b/HashLib/src/Include/HashLib.inc @@ -21,6 +21,13 @@ {$MESSAGE ERROR 'This Library requires Delphi 2010 or higher.'} {$IFEND} + // Silence H2586 (legacy $IFEND) on XE4+ where $ENDIF can also close $IF. + // The $LEGACYIFEND directive itself was introduced in XE4 (25.0), so the + // guard is necessary to keep Delphi 2010 / XE / XE2 / XE3 compiling. + {$IF CompilerVersion >= 25.0} + {$LEGACYIFEND ON} + {$IFEND} + {$DEFINE DELPHI} {$DEFINITIONINFO ON} // Enable code browsing (Ctrl+Click) diff --git a/HashLib/src/Utils/HlpArmHwCapProvider.pas b/HashLib/src/Utils/HlpArmHwCapProvider.pas index f4e73c7..3d269d0 100644 --- a/HashLib/src/Utils/HlpArmHwCapProvider.pas +++ b/HashLib/src/Utils/HlpArmHwCapProvider.pas @@ -139,12 +139,17 @@ implementation class procedure TArmHwCapProvider.ResolveDynamicImports(); var - LHandle: Pointer; + LHandle: NativeUInt; begin FGetAuxVal := nil; +{$IFDEF FPC} + LHandle := NativeUInt(dlopen(nil, RTLD_NOW)); +{$ELSE} LHandle := dlopen(nil, RTLD_NOW); - if LHandle = nil then +{$ENDIF} + + if LHandle = 0 then Exit; try @@ -179,12 +184,17 @@ class function TArmHwCapProvider.GetHwCap2(): UInt64; class procedure TArmHwCapProvider.ResolveDynamicImports(); var - LHandle: Pointer; + LHandle: NativeUInt; begin FElfAuxInfo := nil; +{$IFDEF FPC} + LHandle := NativeUInt(dlopen(nil, RTLD_NOW)); +{$ELSE} LHandle := dlopen(nil, RTLD_NOW); - if LHandle = nil then +{$ENDIF} + + if LHandle = 0 then Exit; try From cf042eb57146e00b2030948860a8554b7674616c Mon Sep 17 00:00:00 2001 From: Ugochukwu Mmaduekwe Date: Sun, 3 May 2026 00:33:18 +0100 Subject: [PATCH 2/2] workaround Delphi Aarch64 Android optimizer bug --- HashLib/src/Crypto/Blake2BParams/HlpBlake2BParams.pas | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/HashLib/src/Crypto/Blake2BParams/HlpBlake2BParams.pas b/HashLib/src/Crypto/Blake2BParams/HlpBlake2BParams.pas index 369ee58..419e04a 100644 --- a/HashLib/src/Crypto/Blake2BParams/HlpBlake2BParams.pas +++ b/HashLib/src/Crypto/Blake2BParams/HlpBlake2BParams.pas @@ -97,7 +97,7 @@ TBlake2BTreeConfig = class sealed(TInterfacedObject, IBlake2BTreeConfig) procedure ValidateInnerHashSize(AInnerHashSize: Byte); inline; procedure ValidateMaxDepth(AMaxDepth: Byte); inline; procedure ValidateNodeDepth(ANodeDepth: Byte); inline; - procedure ValidateNodeOffset(ANodeOffset: UInt64); inline; + procedure ValidateNodeOffset(ANodeOffset: UInt64); function GetFanOut: Byte; inline; procedure SetFanOut(AValue: Byte); inline; @@ -342,9 +342,10 @@ procedure TBlake2BTreeConfig.ValidateNodeDepth(ANodeDepth: Byte); end; procedure TBlake2BTreeConfig.ValidateNodeOffset(ANodeOffset: UInt64); +const + MaxNodeOffset: UInt64 = $FFFFFFFFFFFFFFFF; // (2^64) - 1 begin - // ANodeOffset > ((2^64) - 1) - if ANodeOffset > System.High(UInt64) then + if ANodeOffset > MaxNodeOffset then begin raise EArgumentInvalidHashLibException.CreateRes (@SInvalidNodeOffsetParameter);