2
$Id: system.pp,v 1.6 2005/02/14 17:13:31 peter Exp $
3
This file is part of the Free Pascal run time library.
4
Copyright (c) 1999-2000 by the Free Pascal development team.
8
See the file COPYING.FPC, included in this distribution,
9
for details about the copyright.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
**********************************************************************}
20
{$define FPC_IS_SYSTEM}
22
{ include system-independent routine headers }
33
{ OS independant parts}
37
{*****************************************************************************
38
Misc. System Dependent Functions
39
*****************************************************************************}
43
procedure System_exit;
45
Fpexit(cint(ExitCode));
49
Function ParamCount: Longint;
55
function BackPos(c:char; const s: shortstring): integer;
59
for i:=length(s) downto 0 do
60
if s[i] = c then break;
68
{ variable where full path and filename and executable is stored }
69
{ is setup by the startup of the system unit. }
71
execpathstr : shortstring;
73
function paramstr(l: longint) : string;
78
{ stricly conforming POSIX applications }
79
{ have the executing filename as argv[0] }
82
// paramstr := execpathstr;
85
paramstr:=strpas(argv[l]);
90
randseed:=longint(Fptime(nil));
94
{*****************************************************************************
95
SystemUnit Initialization
96
*****************************************************************************}
98
function reenable_signal(sig : longint) : boolean;
103
fillchar(e,sizeof(e),#0);
104
fillchar(oe,sizeof(oe),#0);
105
{ set is 1 based PM }
110
fpsigprocmask(SIG_UNBLOCK,@e,@oe);
111
reenable_signal:=geterrno=0;
119
Procedure InstallSignals;
121
oldact: SigActionRec;
123
{ Initialize the sigaction structure }
124
{ all flags and information set to zero }
125
FillChar(act, sizeof(SigActionRec),0);
126
{ initialize handler }
127
act.sa_handler :=@SignalToRunError;
128
act.sa_flags:=SA_SIGINFO;
129
FpSigAction(SIGFPE,act,oldact);
130
FpSigAction(SIGSEGV,act,oldact);
131
FpSigAction(SIGBUS,act,oldact);
132
FpSigAction(SIGILL,act,oldact);
136
procedure SetupCmdLine;
146
reallocmem(cmdline,size+bufsize);
147
move(buf^,cmdline[size],bufsize);
159
len:=strlen(argv[i]);
160
if len>ARG_MAX-2 then
164
if argv[i][j]=' ' then
169
if bufsize+len>=ARG_MAX-2 then
176
move(argv[i]^,buf[bufsize],len);
191
FreeMem(buf,ARG_MAX);
195
procedure SysInitStdIO;
197
OpenStdIO(Input,fmInput,StdInputHandle);
198
OpenStdIO(Output,fmOutput,StdOutputHandle);
199
OpenStdIO(ErrOutput,fmOutput,StdErrorHandle);
200
OpenStdIO(StdOut,fmOutput,StdOutputHandle);
201
OpenStdIO(StdErr,fmOutput,StdErrorHandle);
205
function GetProcessID: SizeUInt;
207
GetProcessID := SizeUInt (fpGetPID);
214
StackLength := InitialStkLen;
215
StackBottom := Sptr - StackLength;
216
{ Set up signals handlers }
223
{ Setup stdin, stdout and stderr }
231
{$ifdef HASWIDESTRING}
232
initwidestringmanager;
233
{$endif HASWIDESTRING}
238
Revision 1.6 2005/02/14 17:13:31 peter
241
Revision 1.5 2005/02/14 16:32:41 peter
244
Revision 1.4 2005/02/13 22:13:20 peter
245
* get solaris back in shape
247
Revision 1.3 2005/02/13 21:47:56 peter
248
* include file cleanup part 2
250
Revision 1.2 2005/02/10 17:30:54 peter
253
Revision 1.5 2005/02/07 22:17:26 peter
254
* updated for 1.9.x unix rtl
256
Revision 1.4 2005/02/01 20:22:50 florian
257
* improved widestring infrastructure manager