1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
{
This file is part of the Free Pascal run time library.
Copyright (c) 2016 the Free Pascal development team
Portions based on the Atari RTL for FPC 1.x
Copyright (c) 1999-2000 by Carl Eric Codere
member of the Free Pascal development team
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
unit System;
interface
{$define FPC_IS_SYSTEM}
{$define FPC_STDOUT_TRUE_ALIAS}
{$define FPC_ANSI_TEXTFILEREC}
{$define FPC_ATARI_USE_TINYHEAP}
{$ifdef FPC_ATARI_USE_TINYHEAP}
{$define HAS_MEMORYMANAGER}
{$endif FPC_ATARI_USE_TINYHEAP}
{$i systemh.inc}
{$ifdef FPC_ATARI_USE_TINYHEAP}
{$i tnyheaph.inc}
{$endif FPC_ATARI_USE_TINYHEAP}
{Platform specific information}
const
LineEnding = #13#10;
LFNSupport = false;
CtrlZMarksEOF: boolean = false; (* #26 not considered as end of file *)
DirectorySeparator = '\';
DriveSeparator = ':';
ExtensionSeparator = '.';
PathSeparator = ';';
AllowDirectorySeparators : set of char = ['\','/'];
AllowDriveSeparators : set of char = [':'];
FileNameCaseSensitive = false;
FileNameCasePreserving = false;
maxExitCode = 255;
MaxPathLen = 255;
AllFilesMask = '*.*';
sLineBreak = LineEnding;
DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF;
const
UnusedHandle = $ffff;
StdInputHandle = 0;
StdOutputHandle = 1;
StdErrorHandle = $ffff;
var
args: PChar;
argc: LongInt;
argv: PPChar;
envp: PPChar;
{$if defined(FPUSOFT)}
{$define fpc_softfpu_interface}
{$i softfpu.pp}
{$undef fpc_softfpu_interface}
{$endif defined(FPUSOFT)}
implementation
{$define FPC_SYSTEM_HAS_STACKTOP}
{$define FPC_SYSTEM_HAS_BACKTRACESTR}
{$if defined(FPUSOFT)}
{$define fpc_softfpu_implementation}
{$define softfpu_compiler_mul32to64}
{$define softfpu_inline}
{$i softfpu.pp}
{$undef fpc_softfpu_implementation}
{ we get these functions and types from the softfpu code }
{$define FPC_SYSTEM_HAS_float64}
{$define FPC_SYSTEM_HAS_float32}
{$define FPC_SYSTEM_HAS_flag}
{$define FPC_SYSTEM_HAS_extractFloat64Frac0}
{$define FPC_SYSTEM_HAS_extractFloat64Frac1}
{$define FPC_SYSTEM_HAS_extractFloat64Exp}
{$define FPC_SYSTEM_HAS_extractFloat64Sign}
{$define FPC_SYSTEM_HAS_ExtractFloat32Frac}
{$define FPC_SYSTEM_HAS_extractFloat32Exp}
{$define FPC_SYSTEM_HAS_extractFloat32Sign}
{$endif defined(FPUSOFT)}
{$i system.inc}
{$ifdef FPC_ATARI_USE_TINYHEAP}
{$i tinyheap.inc}
{$endif FPC_ATARI_USE_TINYHEAP}
{$i syspara.inc}
function GetProcessID:SizeUInt;
begin
{$WARNING To be checked by platform maintainer}
GetProcessID := 1;
end;
procedure SysInitParamsAndEnv;
begin
// [0] index contains the args length...
args:=@basepage^.p_cmdlin[1];
GenerateArgs;
end;
procedure randomize;
begin
{$WARNING: randseed initial value is 24bit}
randseed:=xbios_random;
end;
{*****************************************************************************
System Dependent Exit code
*****************************************************************************}
Procedure system_exit;
begin
gemdos_pterm(ExitCode);
end;
{*****************************************************************************
SystemUnit Initialization
*****************************************************************************}
procedure SysInitStdIO;
begin
OpenStdIO(Input,fmInput,StdInputHandle);
OpenStdIO(Output,fmOutput,StdOutputHandle);
OpenStdIO(ErrOutput,fmOutput,StdErrorHandle);
{$ifndef FPC_STDOUT_TRUE_ALIAS}
OpenStdIO(StdOut,fmOutput,StdOutputHandle);
OpenStdIO(StdErr,fmOutput,StdErrorHandle);
{$endif FPC_STDOUT_TRUE_ALIAS}
end;
function CheckInitialStkLen (StkLen: SizeUInt): SizeUInt;
begin
CheckInitialStkLen := StkLen;
end;
begin
StackLength := CheckInitialStkLen (InitialStkLen);
StackBottom := StackTop - StackLength;
StackMargin := min(align(StackLength div 20,2),STACK_MARGIN_MAX);
{ Initialize ExitProc }
ExitProc:=Nil;
{$ifndef FPC_ATARI_USE_TINYHEAP}
{ Setup heap }
InitHeap;
{$endif FPC_ATARI_USE_TINYHEAP}
SysInitExceptions;
{$ifdef FPC_HAS_FEATURE_UNICODESTRINGS}
InitUnicodeStringManager;
{$endif FPC_HAS_FEATURE_UNICODESTRINGS}
{ Setup stdin, stdout and stderr }
SysInitStdIO;
{ Reset IO Error }
InOutRes:=0;
{ Setup command line arguments }
SysInitParamsAndEnv;
{$ifdef FPC_HAS_FEATURE_THREADING}
InitSystemThreads;
{$endif FPC_HAS_FEATURE_THREADING}
end.
|