system.pp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. AllFilesMask = '*';
  31. var
  32. argc:longint=0;
  33. argv:PPAnsiChar;
  34. envp:PPAnsiChar;
  35. implementation
  36. var
  37. StkLen: SizeUInt; external name '__stklen';
  38. bss_end: record end; external name '__bss_end__';
  39. procedure _InitHeap(p: pdword; l: dword); external name 'InitHeap2';
  40. procedure _free(p: pointer); external name 'free2';
  41. function _malloc(l: dword): pointer; external name 'malloc2';
  42. procedure _putchar(ch: char); external name 'putchar';
  43. {I ../mips/setjump.inc}
  44. {$I system.inc}
  45. {$ifndef FPUNONE}
  46. {$ifdef FPC_HAS_FEATURE_SOFTFPU}
  47. {$define fpc_softfpu_implementation}
  48. {$i softfpu.pp}
  49. {$undef fpc_softfpu_implementation}
  50. { we get these functions and types from the softfpu code }
  51. {$define FPC_SYSTEM_HAS_float64}
  52. {$define FPC_SYSTEM_HAS_float32}
  53. {$define FPC_SYSTEM_HAS_flag}
  54. {$define FPC_SYSTEM_HAS_extractFloat64Frac0}
  55. {$define FPC_SYSTEM_HAS_extractFloat64Frac1}
  56. {$define FPC_SYSTEM_HAS_extractFloat64Exp}
  57. {$define FPC_SYSTEM_HAS_extractFloat64Frac}
  58. {$define FPC_SYSTEM_HAS_extractFloat64Sign}
  59. {$define FPC_SYSTEM_HAS_ExtractFloat32Frac}
  60. {$define FPC_SYSTEM_HAS_extractFloat32Exp}
  61. {$define FPC_SYSTEM_HAS_extractFloat32Sign}
  62. {$endif FPC_HAS_FEATURE_SOFTFPU}
  63. {$endif FPUNONE}
  64. procedure Randomize;
  65. begin
  66. randseed:= 1234;
  67. end;
  68. function GetProcessID: LongWord;
  69. begin
  70. result:= 0;
  71. end;
  72. function ParamCount: LongInt;
  73. begin
  74. ParamCount:= 0;
  75. end;
  76. function ParamStr(l: LongInt): ShortString;
  77. begin
  78. result:='';
  79. end;
  80. procedure SysInitStdIO;
  81. begin
  82. OpenStdIO(Input,fmInput,StdInputHandle);
  83. OpenStdIO(Output,fmOutput,StdOutputHandle);
  84. OpenStdIO(ErrOutput,fmOutput,StdErrorHandle);
  85. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  86. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  87. end;
  88. function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt;
  89. begin
  90. result:= stklen;
  91. end;
  92. procedure system_exit;
  93. begin
  94. repeat
  95. until false;
  96. end;
  97. begin
  98. StackLength:=CheckInitialStkLen(stklen);
  99. StackBottom:=Pointer(PtrUInt($80200000)-PtrUInt(StackLength));
  100. { Debug printing via writeln (visible in emulator logs) is possible, so
  101. pretend to be a console application. }
  102. IsConsole := TRUE;
  103. { To be set if this is a library and not a program }
  104. IsLibrary := FALSE;
  105. { Setup heap }
  106. _InitHeap(pdword(@bss_end),PtrUInt(StackBottom)-PtrUInt(@bss_end));
  107. InitHeap;
  108. { Init exceptions }
  109. SysInitExceptions;
  110. { Init unicode strings }
  111. initunicodestringmanager;
  112. { Setup stdin, stdout and stderr }
  113. SysInitStdIO;
  114. { Reset IO Error }
  115. InOutRes:= 0;
  116. end.