si_prc.pp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2016 by the Free Pascal development team
  4. System Entry point for AmigaOS4/PowerPC, Pascal only programs
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit si_prc;
  12. interface
  13. implementation
  14. const
  15. amigaos4_signature: dword = 1; public name '__amigaos4__';
  16. var
  17. AOS_ExecBase: Pointer; public name '_ExecBase';
  18. IExec: Pointer; public name '_IExec';
  19. StkLen: LongInt; external name '__stklen';
  20. StackCookie: LongInt; external name '__stack_cookie';
  21. sysinit_jmpbuf: jmp_buf;
  22. ExitCode: LongInt;
  23. { the definitions in there need AOS_Execbase and IExec }
  24. {$include execd.inc}
  25. {$include execf.inc}
  26. procedure PascalMain; external name 'PASCALMAIN';
  27. { this function must be the first in this unit which contains code }
  28. { apparently, the third argument contains the ExecBase on entry (KB) }
  29. function _FPC_proc_start(arg0: pointer; arg1: pointer; argExecBase: Pointer): longint; cdecl; public name '_start';
  30. begin
  31. AOS_ExecBase:=argExecBase;
  32. IExec:=PExecBase(AOS_ExecBase)^.MainInterface;
  33. { The StackCookie check is only here so the symbol is referenced and
  34. doesn't get striped out }
  35. if StackCookie > 0 then
  36. if setjmp(sysinit_jmpbuf) = 0 then
  37. PascalMain;
  38. _FPC_proc_start:=ExitCode;
  39. end;
  40. procedure _FPC_proc_halt(_ExitCode: longint); cdecl; public name '_haltproc';
  41. begin
  42. ExitCode:=_ExitCode;
  43. longjmp(sysinit_jmpbuf,1);
  44. end;
  45. end.