{ $Id$ This file is part of the Free Pascal Run time library. Copyright (c) 1993,97 by 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. **********************************************************************} {***************************************************************************** This File contains the OS independent declarations of the system unit *****************************************************************************} {**************************************************************************** Support for multiple compiler versions ****************************************************************************} {$i version.inc} {**************************************************************************** Global Types and Constants ****************************************************************************} Type Longint = $80000000..$7fffffff; Integer = -32768..32767; shortint = -128..127; byte = 0..255; Word = 0..65535; { at least declare Turbo Pascal real types } {$IFDEF i386} Double = real; {$ENDIF} { some type aliases } dword = cardinal; longword = cardinal; { Zero - terminated strings } PChar = ^Char; PPChar = ^PChar; { procedure type } TProcedure = Procedure; const { max. values for longint and int} maxLongint = $7fffffff; maxint = 32767; { Compatibility With TP } {$ifdef i386} Test8086 : byte = 2; { Always i386 or newer } Test8087 : byte = 3; { Always 387 or newer. Emulated if needed. } {$endif i386} {$ifdef m68k} Test68000 : byte = 0; { Must be determined at startup for both } Test68881 : byte = 0; {$endif} { max level in dumping on error } Max_Frame_Dump : Word = 20; { Exit Procedure handling consts and types } ExitProc : pointer=nil; Erroraddr: pointer = nil; Errorcode: Word = 0; { file input modes } fmClosed = $D7B0; fmInput = $D7B1; fmOutput = $D7B2; fmInOut = $D7B3; fmAppend = $D7B4; Filemode : byte = 2; var { Standard In- and Output } Output, Input, StdErr : Text; ExitCode, InOutRes : Word; StackBottom, LowestStack, RandSeed : Longint; {**************************************************************************** Processor specific routines ****************************************************************************} Procedure Move(Var source,dest;count:Longint); Procedure FillChar(Var x;count:Longint;Value:Char); Procedure FillChar(Var x;count:Longint;Value:byte); Procedure FillWord(Var x;count:Longint;Value:Word); {**************************************************************************** Math Routines ****************************************************************************} Function lo(w:Word):byte; Function lo(l:Longint):Word; Function lo(i:Integer):byte; Function lo(B: Byte):Byte; Function hi(w:Word):byte; Function hi(i:Integer):byte; Function hi(l:Longint):Word; Function Hi(B : Byte): byte; Procedure Inc(Var i:cardinal); Procedure Inc(Var i:Longint); Procedure Inc(Var i:Integer); Procedure Inc(Var i:Word); Procedure Inc(Var i:shortint); Procedure Inc(Var i:byte); Procedure Inc(Var c:Char); Procedure Inc(Var p:PChar); Procedure Dec(Var i:cardinal); Procedure Dec(Var i:Longint); Procedure Dec(Var i:Integer); Procedure Dec(Var i:Word); Procedure Dec(Var i:shortint); Procedure Dec(Var i:byte); Procedure Dec(Var c:Char); Procedure Dec(Var p:PChar); Function Chr(b:byte):Char; Function Length(s:string):byte; Procedure Dec(Var i:cardinal;a:Longint); Procedure Inc(Var i:cardinal;a:Longint); Procedure Dec(Var i:Longint;a:Longint); Procedure Inc(Var i:Longint;a:Longint); Procedure Dec(Var i:Word;a:Longint); Procedure Inc(Var i:Word;a:Longint); Procedure Dec(Var i:Integer;a:Longint); Procedure Inc(Var i:Integer;a:Longint); Procedure Dec(Var i:byte;a:Longint); Procedure Inc(Var i:byte;a:Longint); Procedure Dec(Var i:shortint;a:Longint); Procedure Inc(Var i:shortint;a:Longint); Procedure Dec(Var c:Char;a:Longint); Procedure Inc(Var c:Char;a:Longint); Procedure Dec(Var p:PChar;a:Longint); Procedure Inc(Var p:PChar;a:Longint); Function Swap (X:Word):Word; Function Swap (X:Integer):Integer; Function Swap (X:Cardinal):Cardinal; Function Swap (X:Longint):Longint; Function Random(l:Longint):Longint; Function Random:real; Procedure Randomize; Function abs(l:Longint):Longint; Function sqr(l:Longint):Longint; Function odd(l:Longint):Boolean; { float mathe routines } {$I mathh.inc} {**************************************************************************** Memory management ****************************************************************************} Procedure getmem(Var p:pointer;Size:Longint); Procedure freemem(Var p:pointer;Size:Longint); Function memavail:Longint; Function maxavail:Longint; Function ptr(sel,off:Longint):pointer; Function Addr (Var X):pointer; Function Cseg:Word; Function Dseg:Word; Function Sseg:Word; {**************************************************************************** PChar Handling ****************************************************************************} function strpas(p:pchar):string; function strlen(p:pchar):longint; {**************************************************************************** String Handling ****************************************************************************} Function copy(const s:string;index:Integer;count:Integer):string; Procedure Delete(Var s:string;index:Integer;count:Integer); Procedure Insert(const source:string;Var s:string;index:Integer); Function Pos(const substr:string;const s:string):byte; Function Pos(C:Char;const s:string):byte; Function upCase(c:Char):Char; Function upCase(const s:string):string; Function lowerCase(c:Char):Char; Function lowerCase(const s:string):string; Function Space(b:byte):string; Function hexStr(Val:Longint;cnt:byte):string; Function binStr(Val:Longint;cnt:byte):string; Procedure Val(const s:string;Var l:Longint;Var code:Word); Procedure Val(const s:string;Var l:Longint;Var code:Integer); Procedure Val(const s:string;Var l:Longint); Procedure Val(const s:string;Var b:byte;Var code:Word); Procedure Val(const s:string;Var b:byte;Var code:Integer); Procedure Val(const s:string;Var b:byte); Procedure Val(const s:string;Var b:shortint;Var code:Word); Procedure Val(const s:string;Var b:shortint;Var code:Integer); Procedure Val(const s:string;Var b:shortint); Procedure Val(const s:string;Var b:Word;Var code:Word); Procedure Val(const s:string;Var b:Word;Var code:Integer); Procedure Val(const s:string;Var b:Word); Procedure Val(const s:string;Var b:Integer;Var code:Word); Procedure Val(const s:string;Var b:Integer;Var code:Integer); Procedure Val(const s:string;Var b:Integer); Procedure Val(const s:string;Var d:Real;Var code:Word); Procedure Val(const s:string;Var d:Real;Var code:Integer); Procedure Val(const s:string;Var d:Real); Procedure Val(const s:string;Var d:single;Var code:Word); Procedure Val(const s:string;Var d:single;Var code:Integer); Procedure Val(const s:string;Var d:single); Procedure Val(const s:string;Var d:Extended;Var code:Word); Procedure Val(const s:string;Var d:Extended;Var code:Integer); Procedure Val(const s:string;Var d:Extended); Procedure Val(const s:string;Var d:comp;Var code:Word); Procedure Val(const s:string;Var d:comp;Var code:Integer); Procedure Val(const s:string;Var d:comp); Procedure Val(const s:string;Var v:cardinal;Var code:Word); Procedure Val(const s:string;Var v:cardinal;Var code:Integer); Procedure Val(const s:string;Var v:cardinal); {**************************************************************************** Untyped File Management ****************************************************************************} Procedure Assign(Var f:File;const Name:string); Procedure Assign(Var f:File;p:pchar); Procedure Assign(Var f:File;c:char); Procedure Rewrite(Var f:File;l:Word); Procedure Rewrite(Var f:File); Procedure Reset(Var f:File;l:Word); Procedure Reset(Var f:File); Procedure Close(Var f:File); Procedure BlockWrite(Var f:File;Var Buf;Count:Longint;Var Result:Longint); Procedure BlockWrite(Var f:File;Var Buf;Count:Word;Var Result:Word); Procedure BlockWrite(Var f:File;Var Buf;Count:Word;Var Result:Integer); Procedure BlockWrite(Var f:File;Var Buf;Count:Longint); Procedure BlockRead(Var f:File;Var Buf;count:Longint;Var Result:Longint); Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Word); Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Integer); Procedure BlockRead(Var f:File;Var Buf;count:Longint); Function FilePos(Var f:File):Longint; Function FileSize(Var f:File):Longint; Procedure Seek(Var f:File;Pos:Longint); Function EOF(Var f:File):Boolean; Procedure Erase(Var f:File); Procedure Rename(Var f:File;const s:string); Procedure Rename(Var f:File;p:pchar); Procedure Rename(Var f:File;c:char); Procedure Truncate (Var F:File); {**************************************************************************** Typed File Management ****************************************************************************} Procedure Assign(Var f:TypedFile;const Name:string); Procedure Assign(Var f:TypedFile;p:pchar); Procedure Assign(Var f:TypedFile;c:char); Procedure Rewrite(Var f:TypedFile); Procedure Reset(Var f:TypedFile); {**************************************************************************** Text File Management ****************************************************************************} Procedure Assign(Var t:Text;const s:string); Procedure Assign(Var t:Text;p:pchar); Procedure Assign(Var t:Text;c:char); Procedure Close(Var t:Text); Procedure Rewrite(Var t:Text); Procedure Reset(Var t:Text); Procedure Append(Var t:Text); Procedure Flush(Var t:Text); Procedure Erase(Var t:Text); Procedure Rename(Var t:Text;const s:string); Procedure Rename(Var t:Text;p:pchar); Procedure Rename(Var t:Text;c:char); Function EOF(Var t:Text):Boolean; Function EOF:Boolean; Function EOLn(Var t:Text):Boolean; Function EOLn:Boolean; Function SeekEOLn (Var F:Text):Boolean; Function SeekEOF (Var F:Text):Boolean; Function SeekEOLn:Boolean; Function SeekEOF:Boolean; Procedure SetTextBuf(Var f:Text; Var Buf); Procedure SetTextBuf(Var f:Text; Var Buf; Size:Word); {**************************************************************************** Directory Management ****************************************************************************} Procedure chdir(const s:string); Procedure mkdir(const s:string); Procedure rmdir(const s:string); Procedure getdir(drivenr:byte;Var dir:string); {***************************************************************************** Miscelleaous *****************************************************************************} Function IOResult:Word; Function Sptr:Longint; {***************************************************************************** Init / Exit / ExitProc *****************************************************************************} Function Paramcount:Longint; Function ParamStr(l:Longint):string; Procedure Dump_Stack(bp:Longint); Procedure RunError(w:Word); Procedure RunError; Procedure halt(errnum:byte); Procedure halt; Procedure AddExitProc(Proc:TProcedure); { $Log$ Revision 1.7 1998-05-22 12:34:11 peter * fixed the optimizes of daniel Revision 1.6 1998/05/21 19:31:00 peter * objects compiles for linux + assign(pchar), assign(char), rename(pchar), rename(char) * fixed read_text_as_array + read_text_as_pchar which was not yet in the rtl Revision 1.5 1998/05/12 10:42:45 peter * moved getopts to inc/, all supported OS's need argc,argv exported + strpas, strlen are now exported in the systemunit * removed logs * removed $ifdef ver_above Revision 1.4 1998/04/16 12:30:47 peter + inc(pchar), dec(pchar), incc(pchar,a),dec(pchar,a) }