system.pp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2016 the Free Pascal development team
  4. Portions based on the Atari RTL for FPC 1.x
  5. Copyright (c) 1999-2000 by Carl Eric Codere
  6. member of the Free Pascal development team
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. unit System;
  14. {--------------------------------------------------------------------}
  15. { LEFT TO DO: }
  16. {--------------------------------------------------------------------}
  17. { o SBrk }
  18. { o Implement truncate }
  19. { o Implement paramstr(0) }
  20. {--------------------------------------------------------------------}
  21. interface
  22. {$I systemh.inc}
  23. {Platform specific information}
  24. const
  25. LineEnding = #13#10;
  26. LFNSupport = false;
  27. CtrlZMarksEOF: boolean = false; (* #26 not considered as end of file *)
  28. DirectorySeparator = '\';
  29. DriveSeparator = ':';
  30. ExtensionSeparator = '.';
  31. PathSeparator = ';';
  32. AllowDirectorySeparators : set of char = ['\','/'];
  33. AllowDriveSeparators : set of char = [':'];
  34. FileNameCaseSensitive = false;
  35. FileNameCasePreserving = false;
  36. maxExitCode = 255;
  37. MaxPathLen = 255;
  38. AllFilesMask = '*.*';
  39. sLineBreak = LineEnding;
  40. DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF;
  41. const
  42. UnusedHandle = $ffff;
  43. StdInputHandle = 0;
  44. StdOutputHandle = 1;
  45. StdErrorHandle = $ffff;
  46. var
  47. args: PChar;
  48. argc: LongInt;
  49. argv: PPChar;
  50. envp: PPChar;
  51. {$if defined(FPUSOFT)}
  52. {$define fpc_softfpu_interface}
  53. {$i softfpu.pp}
  54. {$undef fpc_softfpu_interface}
  55. {$endif defined(FPUSOFT)}
  56. implementation
  57. {$if defined(FPUSOFT)}
  58. {$define fpc_softfpu_implementation}
  59. {$i softfpu.pp}
  60. {$undef fpc_softfpu_implementation}
  61. { we get these functions and types from the softfpu code }
  62. {$define FPC_SYSTEM_HAS_float64}
  63. {$define FPC_SYSTEM_HAS_float32}
  64. {$define FPC_SYSTEM_HAS_flag}
  65. {$define FPC_SYSTEM_HAS_extractFloat64Frac0}
  66. {$define FPC_SYSTEM_HAS_extractFloat64Frac1}
  67. {$define FPC_SYSTEM_HAS_extractFloat64Exp}
  68. {$define FPC_SYSTEM_HAS_extractFloat64Sign}
  69. {$define FPC_SYSTEM_HAS_ExtractFloat32Frac}
  70. {$define FPC_SYSTEM_HAS_extractFloat32Exp}
  71. {$define FPC_SYSTEM_HAS_extractFloat32Sign}
  72. {$endif defined(FPUSOFT)}
  73. {$I system.inc}
  74. {$I syspara.inc}
  75. var
  76. basepage: PPD; external name '__base';
  77. function GetProcessID:SizeUInt;
  78. begin
  79. {$WARNING To be checked by platform maintainer}
  80. GetProcessID := 1;
  81. end;
  82. {$S-}
  83. (* procedure Stack_Check; assembler;
  84. { Check for local variable allocation }
  85. { On Entry -> d0 : size of local stack we are trying to allocate }
  86. asm
  87. XDEF STACKCHECK
  88. move.l sp,d1 { get value of stack pointer }
  89. sub.l d0,d1 { sp - stack_size }
  90. sub.l #2048,d1
  91. cmp.l __BREAK,d1
  92. bgt @st1nosweat
  93. move.l #202,d0
  94. jsr HALT_ERROR
  95. @st1nosweat:
  96. end;*)
  97. procedure SysInitParamsAndEnv;
  98. begin
  99. // [0] index contains the args length...
  100. args:=@basepage^.p_cmdlin[1];
  101. GenerateArgs;
  102. end;
  103. { This routine is used to grow the heap. }
  104. { But here we do a trick, we say that the }
  105. { heap cannot be regrown! }
  106. function sbrk( size: longint): pointer;
  107. { on exit nil = if fails. }
  108. Begin
  109. sbrk:=nil;
  110. end;
  111. procedure randomize;
  112. begin
  113. {$WARNING: randseed initial value is 24bit}
  114. randseed:=xbios_random;
  115. end;
  116. {*****************************************************************************
  117. System Dependent Exit code
  118. *****************************************************************************}
  119. Procedure system_exit;
  120. begin
  121. gemdos_pterm(ExitCode);
  122. end;
  123. {*****************************************************************************
  124. SystemUnit Initialization
  125. *****************************************************************************}
  126. procedure SysInitStdIO;
  127. begin
  128. OpenStdIO(Input,fmInput,StdInputHandle);
  129. OpenStdIO(Output,fmOutput,StdOutputHandle);
  130. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  131. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  132. OpenStdIO(ErrOutput,fmOutput,StdErrorHandle);
  133. end;
  134. function CheckInitialStkLen (StkLen: SizeUInt): SizeUInt;
  135. begin
  136. CheckInitialStkLen := StkLen;
  137. end;
  138. begin
  139. StackLength := CheckInitialStkLen (InitialStkLen);
  140. { Initialize ExitProc }
  141. ExitProc:=Nil;
  142. { Setup heap }
  143. InitHeap;
  144. SysInitExceptions;
  145. InitUnicodeStringManager;
  146. { Setup stdin, stdout and stderr }
  147. SysInitStdIO;
  148. { Reset IO Error }
  149. InOutRes:=0;
  150. { Setup command line arguments }
  151. SysInitParamsAndEnv;
  152. {$ifdef FPC_HAS_FEATURE_THREADING}
  153. InitSystemThreads;
  154. {$endif}
  155. end.