system.pp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. interface
  15. {$define FPC_STDOUT_TRUE_ALIAS}
  16. {$define FPC_ANSI_TEXTFILEREC}
  17. {$define FPC_ATARI_USE_TINYHEAP}
  18. {$ifdef FPC_ATARI_USE_TINYHEAP}
  19. {$define HAS_MEMORYMANAGER}
  20. {$endif FPC_ATARI_USE_TINYHEAP}
  21. {$i systemh.inc}
  22. {$ifdef FPC_ATARI_USE_TINYHEAP}
  23. {$i tnyheaph.inc}
  24. {$endif FPC_ATARI_USE_TINYHEAP}
  25. {Platform specific information}
  26. const
  27. LineEnding = #13#10;
  28. LFNSupport = false;
  29. CtrlZMarksEOF: boolean = false; (* #26 not considered as end of file *)
  30. DirectorySeparator = '\';
  31. DriveSeparator = ':';
  32. ExtensionSeparator = '.';
  33. PathSeparator = ';';
  34. AllowDirectorySeparators : set of char = ['\','/'];
  35. AllowDriveSeparators : set of char = [':'];
  36. FileNameCaseSensitive = false;
  37. FileNameCasePreserving = false;
  38. maxExitCode = 255;
  39. MaxPathLen = 255;
  40. AllFilesMask = '*.*';
  41. sLineBreak = LineEnding;
  42. DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF;
  43. const
  44. UnusedHandle = $ffff;
  45. StdInputHandle = 0;
  46. StdOutputHandle = 1;
  47. StdErrorHandle = 2;
  48. var
  49. args: PChar;
  50. argc: LongInt;
  51. argv: PPChar;
  52. envp: PPChar;
  53. {$if defined(FPUSOFT)}
  54. {$define fpc_softfpu_interface}
  55. {$i softfpu.pp}
  56. {$undef fpc_softfpu_interface}
  57. {$endif defined(FPUSOFT)}
  58. implementation
  59. {$if defined(FPUSOFT)}
  60. {$define fpc_softfpu_implementation}
  61. {$define softfpu_compiler_mul32to64}
  62. {$define softfpu_inline}
  63. {$i softfpu.pp}
  64. {$undef fpc_softfpu_implementation}
  65. { we get these functions and types from the softfpu code }
  66. {$define FPC_SYSTEM_HAS_float64}
  67. {$define FPC_SYSTEM_HAS_float32}
  68. {$define FPC_SYSTEM_HAS_flag}
  69. {$define FPC_SYSTEM_HAS_extractFloat64Frac0}
  70. {$define FPC_SYSTEM_HAS_extractFloat64Frac1}
  71. {$define FPC_SYSTEM_HAS_extractFloat64Exp}
  72. {$define FPC_SYSTEM_HAS_extractFloat64Sign}
  73. {$define FPC_SYSTEM_HAS_ExtractFloat32Frac}
  74. {$define FPC_SYSTEM_HAS_extractFloat32Exp}
  75. {$define FPC_SYSTEM_HAS_extractFloat32Sign}
  76. {$endif defined(FPUSOFT)}
  77. {$i system.inc}
  78. {$ifdef FPC_ATARI_USE_TINYHEAP}
  79. {$i tinyheap.inc}
  80. {$endif FPC_ATARI_USE_TINYHEAP}
  81. {$i syspara.inc}
  82. var
  83. basepage: PPD; external name '__base';
  84. function GetProcessID:SizeUInt;
  85. begin
  86. {$WARNING To be checked by platform maintainer}
  87. GetProcessID := 1;
  88. end;
  89. procedure SysInitParamsAndEnv;
  90. begin
  91. // [0] index contains the args length...
  92. args:=@basepage^.p_cmdlin[1];
  93. GenerateArgs;
  94. end;
  95. procedure randomize;
  96. begin
  97. {$WARNING: randseed initial value is 24bit}
  98. randseed:=xbios_random;
  99. end;
  100. {*****************************************************************************
  101. System Dependent Exit code
  102. *****************************************************************************}
  103. Procedure system_exit;
  104. begin
  105. gemdos_pterm(ExitCode);
  106. end;
  107. {*****************************************************************************
  108. SystemUnit Initialization
  109. *****************************************************************************}
  110. procedure SysInitStdIO;
  111. begin
  112. OpenStdIO(Input,fmInput,StdInputHandle);
  113. OpenStdIO(Output,fmOutput,StdOutputHandle);
  114. OpenStdIO(ErrOutput,fmOutput,StdErrorHandle);
  115. {$ifndef FPC_STDOUT_TRUE_ALIAS}
  116. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  117. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  118. {$endif FPC_STDOUT_TRUE_ALIAS}
  119. end;
  120. function CheckInitialStkLen (StkLen: SizeUInt): SizeUInt;
  121. begin
  122. CheckInitialStkLen := StkLen;
  123. end;
  124. begin
  125. StackLength := CheckInitialStkLen (InitialStkLen);
  126. { Initialize ExitProc }
  127. ExitProc:=Nil;
  128. {$ifndef FPC_ATARI_USE_TINYHEAP}
  129. { Setup heap }
  130. InitHeap;
  131. {$endif FPC_ATARI_USE_TINYHEAP}
  132. SysInitExceptions;
  133. {$ifdef FPC_HAS_FEATURE_UNICODESTRINGS}
  134. InitUnicodeStringManager;
  135. {$endif FPC_HAS_FEATURE_UNICODESTRINGS}
  136. { Setup stdin, stdout and stderr }
  137. SysInitStdIO;
  138. { Reset IO Error }
  139. InOutRes:=0;
  140. { Setup command line arguments }
  141. SysInitParamsAndEnv;
  142. {$ifdef FPC_HAS_FEATURE_THREADING}
  143. InitSystemThreads;
  144. {$endif FPC_HAS_FEATURE_THREADING}
  145. end.