Skip to content

Commit

Permalink
* [Packages] Fix some Win64 Support Problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuXiao950 authored and LiuXiao950 committed Nov 10, 2018
1 parent 8e3a72d commit 55c0736
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Packages/Delphi102T/CnPack_D102T.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<DCC_OutputNeverBuildDcps>true</DCC_OutputNeverBuildDcps>
<DCC_Description>CnPack Components Runtime Package</DCC_Description>
<DCC_ImageBase>00400000</DCC_ImageBase>
<DCC_Namespace>Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;System.Win;$(DCC_Namespace)</DCC_Namespace>
<DCC_Namespace>Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Xml.Win;Data;Data.Win;Datasnap;Web;Soap;Winapi;System.Win;$(DCC_Namespace)</DCC_Namespace>
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName=;CFBundleDisplayName=;CFBundleIdentifier=;CFBundleVersion=;CFBundlePackageType=;CFBundleSignature=;CFBundleAllowMixedLocalizations=;CFBundleExecutable=</VerInfo_Keys>
<DCC_N>false</DCC_N>
<DCC_S>false</DCC_S>
Expand Down Expand Up @@ -317,6 +317,7 @@
</Delphi.Personality>
<Platforms>
<Platform value="Win32">True</Platform>
<Platform value="Win64">True</Platform>
</Platforms>
<Deployment Version="3">
<DeployFile LocalName="C:\Users\Public\Documents\Embarcadero\Studio\19.0\Bpl\CnPack_D102T.bpl" Configuration="Release" Class="ProjectOutput">
Expand Down
8 changes: 8 additions & 0 deletions Source/Common/CnBigNumber.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1648,6 +1648,8 @@ procedure BigNumberSqrWords(RP: PDWordArray; AP: PDWordArray; N: Integer);
end;
end;

{$IFNDEF WIN64}

// Dividend(EAX(lo):EDX(hi)), Divisor([ESP+8](hi):[ESP+4](lo))
// 来自 Delphi 的 Unsigned Int64 Div 汇编实现
procedure _LLUDiv;
Expand Down Expand Up @@ -1707,6 +1709,8 @@ procedure _LLUDiv;
JMP @__LLUDIV@FINISH
end;

{$ENDIF}

// 64 位被除数整除 32 位除数,返回商,Result := H L div D
function BigNumberDivWords(H: DWORD; L: DWORD; D: DWORD): DWORD;
begin
Expand All @@ -1716,6 +1720,9 @@ function BigNumberDivWords(H: DWORD; L: DWORD; D: DWORD): DWORD;
Exit;
end;

{$IFDEF WIN64}
Result := DWORD(((UInt64(H) shl 32) or UInt64(L)) div UInt64(D));
{$ELSE}
Result := 0;
asm
PUSH 0
Expand All @@ -1725,6 +1732,7 @@ function BigNumberDivWords(H: DWORD; L: DWORD; D: DWORD): DWORD;
CALL _LLUDiv // 使用汇编实现的 64 位无符号除法函数
MOV Result, EAX
end;
{$ENDIF}
end;

{* Words 系列内部计算函数结束 }
Expand Down
15 changes: 15 additions & 0 deletions Source/Common/CnNativeDecl.pas
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ function Int64Mod(M, N: Int64): Int64;

implementation

{$IFDEF WIN64}

function UInt64Mod(A, B: TUInt64): TUInt64;
begin
Result := A mod B;
end;

function UInt64Div(A, B: TUInt64): TUInt64;
begin
Result := A div B;
end;

{$ELSE}
{
UInt64 求 A mod B
Expand Down Expand Up @@ -153,6 +166,8 @@ function UInt64Div(A, B: TUInt64): TUInt64;
CALL System.@_lludiv;
end;

{$ENDIF}

function _ValUInt64(const S: string; var Code: Integer): TUInt64;
const
FirstIndex = 1;
Expand Down

0 comments on commit 55c0736

Please sign in to comment.