Skip to content

Instantly share code, notes, and snippets.

@Sorien
Created January 14, 2016 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sorien/5235bdfab2c33dd11ece to your computer and use it in GitHub Desktop.
Save Sorien/5235bdfab2c33dd11ece to your computer and use it in GitHub Desktop.
procedure InitUnits;
var
Count, I: Integer;
Table: PUnitEntryTable;
P: Pointer;
begin
if InitContext.InitTable = nil then
exit;
Count := InitContext.InitTable^.UnitCount;
I := 0;
Table := InitContext.InitTable^.UnitInfo;
{$IFDEF LINUX}
Inc(Cardinal(Table), InitContext.Module^.GOT);
{$ENDIF}
try
while I < Count do
begin
P := Table^[I].Init;
Inc(I);
InitContext.InitCount := I;
if Assigned(P) then
begin
{$IFDEF LINUX}
CallProc(P, InitContext.Module^.GOT);
{$ENDIF}
{$IFDEF MSWINDOWS}
TProc(P)();
{$ENDIF}
end;
end;
except
FinalizeUnits;
raise;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment