* automatically create omf libraries with the smallest page size possible. This

greatly reduces the size of i8086 snapshots by keeping the amount of padding
  in the library files to the minimum.

git-svn-id: trunk@39195 -
This commit is contained in:
nickysn 2018-06-07 22:27:47 +00:00
parent 345713c1fa
commit 3f5577077a

View File

@ -78,6 +78,7 @@ type
procedure WriteHeader(DictStart: DWord; DictBlocks: Word); procedure WriteHeader(DictStart: DWord; DictBlocks: Word);
procedure WriteFooter; procedure WriteFooter;
function TryPageSize(aPageSize: Integer): Boolean; function TryPageSize(aPageSize: Integer): Boolean;
procedure DeterminePageSize;
procedure WriteLib; procedure WriteLib;
function WriteDictionary: Word; function WriteDictionary: Word;
function TryWriteDictionaryWithSize(nblocks: Word): Boolean; function TryWriteDictionaryWithSize(nblocks: Word): Boolean;
@ -185,7 +186,7 @@ implementation
constructor TOmfLibObjectWriter.createAr(const Aarfn: string); constructor TOmfLibObjectWriter.createAr(const Aarfn: string);
begin begin
createAr(Aarfn,512); createAr(Aarfn,-1);
end; end;
constructor TOmfLibObjectWriter.createAr(const Aarfn: string;PageSize: Integer); constructor TOmfLibObjectWriter.createAr(const Aarfn: string;PageSize: Integer);
@ -319,6 +320,19 @@ implementation
Result:=True; Result:=True;
end; end;
procedure TOmfLibObjectWriter.DeterminePageSize;
var
I: Integer;
begin
if (FPageSize<>-1) and TryPageSize(FPageSize) then
{ success }
exit;
for I:=4 to 15 do
if TryPageSize(1 shl I) then
exit;
internalerror(2018060703);
end;
procedure TOmfLibObjectWriter.WriteLib; procedure TOmfLibObjectWriter.WriteLib;
var var
libf: TCCustomFileStream; libf: TCCustomFileStream;
@ -327,7 +341,7 @@ implementation
I: Integer; I: Integer;
buf: array [0..1023] of Byte; buf: array [0..1023] of Byte;
begin begin
TryPageSize(512); DeterminePageSize;
libf:=CFileStreamClass.Create(FLibName,fmCreate); libf:=CFileStreamClass.Create(FLibName,fmCreate);
if CStreamError<>0 then if CStreamError<>0 then
begin begin