si_prc.pp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 MorphOS, 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. abox_signature: dword = 1; public name '__abox__';
  16. var
  17. MOS_ExecBase: Pointer; public name '_ExecBase';
  18. realExecBase: Pointer absolute $4;
  19. StkLen: LongInt; external name '__stklen';
  20. sysinit_jmpbuf: jmp_buf;
  21. ExitCode: LongInt;
  22. { the definitions in there need MOS_Execbase }
  23. {$include execd.inc}
  24. {$include execf.inc}
  25. procedure PascalMainEntry; cdecl; forward;
  26. { this function must be the first in this unit which contains code }
  27. function _FPC_proc_start: longint; cdecl; public name '_start';
  28. var
  29. sst: TStackSwapStruct;
  30. newStack: Pointer;
  31. newStackAligned: Pointer;
  32. begin
  33. MOS_ExecBase:=realExecBase;
  34. newStack:=AllocVecTaskPooled(StkLen+16);
  35. newStackAligned:=align(newStack,16);
  36. sst.stk_Lower:=newStackAligned;
  37. sst.stk_Upper:=newStackAligned+StkLen;
  38. sst.stk_Pointer:=newStackAligned+StkLen;
  39. NewPPCStackSwap(@sst,@PascalMainEntry,nil);
  40. FreeVecTaskPooled(newStack);
  41. _FPC_proc_start:=ExitCode;
  42. end;
  43. procedure _FPC_proc_halt(_ExitCode: longint); cdecl; public name '_haltproc';
  44. begin
  45. ExitCode:=_ExitCode;
  46. longjmp(sysinit_jmpbuf,1);
  47. end;
  48. procedure PascalMain; external name 'PASCALMAIN';
  49. procedure PascalMainEntry; cdecl;
  50. begin
  51. if setjmp(sysinit_jmpbuf) = 0 then
  52. PascalMain;
  53. end;
  54. end.