system.pp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. unit system;
  2. interface
  3. {$define FPC_IS_SYSTEM}
  4. {$DEFINE FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
  5. {$I systemh.inc}
  6. {$ifndef FPUNONE}
  7. {$ifdef FPC_HAS_FEATURE_SOFTFPU}
  8. {$define fpc_softfpu_interface}
  9. {$i softfpu.pp}
  10. {$undef fpc_softfpu_interface}
  11. {$endif FPC_HAS_FEATURE_SOFTFPU}
  12. {$endif FPUNONE}
  13. const
  14. maxExitCode = 255;
  15. AllowDirectorySeparators : set of AnsiChar = ['\','/'];
  16. DirectorySeparator = '/';
  17. { Default filehandles }
  18. UnusedHandle = $ffff;{ instead of -1, as it is a word value}
  19. StdInputHandle = 0;
  20. StdOutputHandle = 1;
  21. StdErrorHandle = 2;
  22. CtrlZMarksEOF: boolean = true; (* #26 is considered as end of file *)
  23. DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsLF;
  24. LineEnding = #10;
  25. PathSeparator = '/';
  26. MaxPathLen = 255;
  27. LFNSupport = true;
  28. FileNameCaseSensitive = true;
  29. sLineBreak = #10;
  30. var
  31. argc:longint=0;
  32. argv:PPAnsiChar;
  33. envp:PPAnsiChar;
  34. implementation
  35. var
  36. StkLen: SizeUInt; external name '__stklen';
  37. bss_end: record end; external name '__bss_end__';
  38. procedure _InitHeap(p: pdword; l: dword); external name 'InitHeap2';
  39. procedure _free(p: pointer); external name 'free2';
  40. function _malloc(l: dword): pointer; external name 'malloc2';
  41. procedure _putchar(ch: char); external name 'putchar';
  42. {I ../mips/setjump.inc}
  43. {$I system.inc}
  44. {$ifndef FPUNONE}
  45. {$ifdef FPC_HAS_FEATURE_SOFTFPU}
  46. {$define fpc_softfpu_implementation}
  47. {$i softfpu.pp}
  48. {$undef fpc_softfpu_implementation}
  49. { we get these functions and types from the softfpu code }
  50. {$define FPC_SYSTEM_HAS_float64}
  51. {$define FPC_SYSTEM_HAS_float32}
  52. {$define FPC_SYSTEM_HAS_flag}
  53. {$define FPC_SYSTEM_HAS_extractFloat64Frac0}
  54. {$define FPC_SYSTEM_HAS_extractFloat64Frac1}
  55. {$define FPC_SYSTEM_HAS_extractFloat64Exp}
  56. {$define FPC_SYSTEM_HAS_extractFloat64Frac}
  57. {$define FPC_SYSTEM_HAS_extractFloat64Sign}
  58. {$define FPC_SYSTEM_HAS_ExtractFloat32Frac}
  59. {$define FPC_SYSTEM_HAS_extractFloat32Exp}
  60. {$define FPC_SYSTEM_HAS_extractFloat32Sign}
  61. {$endif FPC_HAS_FEATURE_SOFTFPU}
  62. {$endif FPUNONE}
  63. procedure Randomize;
  64. begin
  65. randseed:= 1234;
  66. end;
  67. function GetProcessID: LongWord;
  68. begin
  69. result:= 0;
  70. end;
  71. function ParamCount: LongInt;
  72. begin
  73. ParamCount:= 0;
  74. end;
  75. function ParamStr(l: LongInt): ShortString;
  76. begin
  77. result:='';
  78. end;
  79. procedure SysInitStdIO;
  80. begin
  81. OpenStdIO(Input,fmInput,StdInputHandle);
  82. OpenStdIO(Output,fmOutput,StdOutputHandle);
  83. OpenStdIO(ErrOutput,fmOutput,StdErrorHandle);
  84. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  85. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  86. end;
  87. function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt;
  88. begin
  89. result:= stklen;
  90. end;
  91. procedure system_exit;
  92. begin
  93. repeat
  94. until false;
  95. end;
  96. begin
  97. StackLength:=CheckInitialStkLen(stklen);
  98. StackBottom:=Pointer(PtrUInt($80200000)-PtrUInt(StackLength));
  99. { Debug printing via writeln (visible in emulator logs) is possible, so
  100. pretend to be a console application. }
  101. IsConsole := TRUE;
  102. { To be set if this is a library and not a program }
  103. IsLibrary := FALSE;
  104. { Setup heap }
  105. _InitHeap(pdword(@bss_end),PtrUInt(StackBottom)-PtrUInt(@bss_end));
  106. InitHeap;
  107. { Init exceptions }
  108. SysInitExceptions;
  109. { Init unicode strings }
  110. initunicodestringmanager;
  111. { Setup stdin, stdout and stderr }
  112. SysInitStdIO;
  113. InOutRes:= 0;
  114. end.