Browse Source

Prepare Linux System unit for working with indirect main information.

rtl/linux/sysosh.inc:
  + add linux specific TPlatform type to be used by TEntryInformation
rtl/linux/system.pp:
  + add EntryInformation variable
  + add common entry point that sets up the tables and calls PascalMain
  * System_exit: adjust to call EntryInformation.Platform.haltproc if indirect main information is used

git-svn-id: branches/svenbarth/packages@32486 -
svenbarth 9 years ago
parent
commit
8d864dd055
2 changed files with 54 additions and 3 deletions
  1. 12 0
      rtl/linux/sysosh.inc
  2. 42 3
      rtl/linux/system.pp

+ 12 - 0
rtl/linux/sysosh.inc

@@ -36,5 +36,17 @@ type
     end;
   end;
 
+{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}
+{$define HAS_ENTRYINFORMATION_PLATFORM}
+  THaltProcProcedure = procedure(e: LongInt);cdecl;
+
+  TPlatformEntryInformation = record
+    argc: longint;
+    argv: ppchar;
+    envp: ppchar;
+    stkptr: pointer;
+    haltproc: THaltProcProcedure;
+  end;
+{$endif}
 
 

+ 42 - 3
rtl/linux/system.pp

@@ -75,25 +75,66 @@ const calculated_cmdline:Pchar=nil;
 
 {$endif defined(CPUARM) or defined(CPUM68K) or (defined(CPUSPARC) and defined(VER2_6))}
 
+{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}
+var
+  EntryInformation : TEntryInformation;
+{$endif FPC_HAS_INDIRECT_MAIN_INFORMATION}
+
 {$I system.inc}
 
 {*****************************************************************************
-                       Misc. System Dependent Functions
+                       Indirect Entry Point
 *****************************************************************************}
 
+{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}
+var
+  FPCResStrInitTables : Pointer;public name '_FPC_ResStrInitTables';
+  FPCResourceStringTables : Pointer;public name '_FPC_ResourceStringTables';
+  initialstkptr : Pointer;
+
+procedure SysEntry(constref info: TEntryInformation);[public,alias:'FPC_SysEntry'];
+begin
+  EntryInformation := info;
+  argc := EntryInformation.Platform.argc;
+  argv := EntryInformation.Platform.argv;
+  envp := EntryInformation.Platform.envp;
+  initialstkptr := EntryInformation.Platform.stkptr;
+  FPCResStrInitTables := EntryInformation.ResStrInitTables;
+  FPCResourceStringTables := EntryInformation.ResourceStringTables;
+{$ifdef cpui386}
+  Set8087CW(Default8087CW);
+{$endif cpui386}
+  EntryInformation.PascalMain();
+end;
+
+{$else FPC_HAS_INDIRECT_MAIN_INFORMATION}
+var
+  initialstkptr : Pointer;external name '__stkptr';
+
 {$if defined(CPUARM) and defined(FPC_ABI_EABI)}
 procedure haltproc(e:longint);cdecl;external name '_haltproc_eabi';
 {$else}
 procedure haltproc(e:longint);cdecl;external name '_haltproc';
 {$endif}
 
+{$endif FPC_HAS_INDIRECT_MAIN_INFORMATION}
+
+
+{*****************************************************************************
+                       Misc. System Dependent Functions
+*****************************************************************************}
+
 {$ifdef FPC_USE_LIBC}
 function  FpPrCtl(options : cInt; const args : ptruint) : cint; cdecl; external clib name 'prctl';
 {$endif}
 
 procedure System_exit;
 begin
+{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}
+  EntryInformation.Platform.haltproc(ExitCode);
+{$else FPC_HAS_INDIRECT_MAIN_INFORMATION}
   haltproc(ExitCode);
+{$endif FPC_HAS_INDIRECT_MAIN_INFORMATION}
 End;
 
 
@@ -333,8 +374,6 @@ begin
     result := stklen;
 end;
 
-var
-  initialstkptr : Pointer;external name '__stkptr';
 begin
 {$if defined(i386) and not defined(FPC_USE_LIBC)}
   InitSyscallIntf;