systemh.inc 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Run time library.
  4. Copyright (c) 1999-2000 by the Free Pascal development team
  5. This File contains the OS independent declarations of the system unit
  6. See the File COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {****************************************************************************
  13. Needed switches
  14. ****************************************************************************}
  15. {$I-,Q-,H-,R-,V-}
  16. {$mode objfpc}
  17. { Using inlining for small system functions/wrappers }
  18. {$ifdef HASINLINE}
  19. {$inline on}
  20. {$define SYSTEMINLINE}
  21. {$endif}
  22. { Use threadvars when the compiler supports it }
  23. {$ifdef HASTHREADVAR}
  24. {$define SUPPORT_THREADVAR}
  25. {$endif HASTHREADVAR}
  26. { don't use FPU registervariables on the i386 }
  27. {$ifdef i386}
  28. {$maxfpuregisters 0}
  29. {$endif i386}
  30. { needed for insert,delete,readln }
  31. {$P+}
  32. { stack checking always disabled
  33. for system unit. This is because
  34. the startup code might not
  35. have been called yet when we
  36. get a stack error, this will
  37. cause big crashes
  38. }
  39. {$S-}
  40. {****************************************************************************
  41. Global Types and Constants
  42. ****************************************************************************}
  43. Type
  44. ShortInt = -128..127;
  45. SmallInt = -32768..32767;
  46. { can't use -2147483648 because of a bug in 1.0.2's val() procedure (JM) }
  47. Longint = +(-2147483647-1)..$7fffffff;
  48. Byte = 0..255;
  49. Word = 0..65535;
  50. {$ifndef ver1_0}
  51. DWord = LongWord;
  52. Cardinal = LongWord;
  53. {$else}
  54. Longword = cardinal;
  55. Dword = cardinal;
  56. {$endif}
  57. Integer = SmallInt;
  58. {$ifdef i386}
  59. StrLenInt = LongInt;
  60. {$define DEFAULT_EXTENDED}
  61. {$define SUPPORT_SINGLE}
  62. {$define SUPPORT_DOUBLE}
  63. {$define SUPPORT_EXTENDED}
  64. {$define SUPPORT_COMP}
  65. ValSInt = Longint;
  66. ValUInt = Cardinal;
  67. ValReal = Extended;
  68. {$endif i386}
  69. {$ifdef x86_64}
  70. StrLenInt = LongInt;
  71. {$define DEFAULT_EXTENDED}
  72. {$define SUPPORT_SINGLE}
  73. {$define SUPPORT_DOUBLE}
  74. {$define SUPPORT_EXTENDED}
  75. {$define SUPPORT_COMP}
  76. ValSInt = Longint;
  77. ValUInt = Cardinal;
  78. ValReal = Extended;
  79. {$endif x86_64}
  80. {$ifdef m68k}
  81. StrLenInt = Longint;
  82. ValSInt = Longint;
  83. ValUInt = Cardinal;
  84. ValReal = Real;
  85. { Comp type does not exist on fpu }
  86. Comp = int64;
  87. {$define SUPPORT_SINGLE}
  88. {$IFDEF Unix}
  89. { Linux FPU emulator will be used }
  90. {$define SUPPORT_DOUBLE}
  91. {$ENDIF}
  92. {$IFOPT E-}
  93. { If not compiling with emulation }
  94. { then support double type. }
  95. {$define SUPPORT_DOUBLE}
  96. {$ENDIF}
  97. {$endif}
  98. {$ifdef powerpc}
  99. StrLenInt = LongInt;
  100. {$define DEFAULT_DOUBLE}
  101. {$define SUPPORT_SINGLE}
  102. {$define SUPPORT_DOUBLE}
  103. ValSInt = Longint;
  104. ValUInt = Cardinal;
  105. ValReal = Double;
  106. { map comp to int64, but this doesn't mean to compile the comp support in! }
  107. Comp = Int64;
  108. {$endif powerpc}
  109. {$ifdef sparc}
  110. StrLenInt = LongInt;
  111. {$define DEFAULT_DOUBLE}
  112. {$define SUPPORT_SINGLE}
  113. {$define SUPPORT_DOUBLE}
  114. ValSInt = Longint;
  115. ValUInt = Cardinal;
  116. ValReal = Double;
  117. { map comp to int64, but this doesn't mean to compile the comp support in! }
  118. Comp = Int64;
  119. {$endif sparc}
  120. { Zero - terminated strings }
  121. PChar = ^Char;
  122. PPChar = ^PChar;
  123. TAnsiChar = Char;
  124. AnsiChar = TAnsiChar;
  125. PAnsiChar = ^TAnsiChar;
  126. PPAnsiChar = ^PAnsiChar;
  127. // UCS4Char = type LongWord;
  128. UCS4Char = LongWord;
  129. PUCS4Char = ^UCS4Char;
  130. TUCS4CharArray = array[0..$effffff] of UCS4Char;
  131. PUCS4CharArray = ^TUCS4CharArray;
  132. {$ifndef VER1_0}
  133. UCS4String = array of UCS4Char;
  134. {$endif VER1_0}
  135. // UTF8String = type ansistring;
  136. UTF8String = ansistring;
  137. PUTF8String = ^UTF8String;
  138. {$ifndef HASCURRENCY}
  139. Currency = Int64;
  140. {$endif HASCURRENCY}
  141. HRESULT = Longint;
  142. TDateTime = Double;
  143. Error = Longint;
  144. PSingle = ^Single;
  145. PDouble = ^Double;
  146. PCurrency = ^Currency;
  147. {$ifdef SUPPORT_COMP}
  148. PComp = ^Comp;
  149. {$endif SUPPORT_COMP}
  150. PExtended = ^Extended;
  151. PSmallInt = ^Smallint;
  152. PShortInt = ^Shortint;
  153. PInteger = ^Longint;
  154. PByte = ^Byte;
  155. PWord = ^word;
  156. PDWord = ^DWord;
  157. PLongWord = ^LongWord;
  158. PLongint = ^Longint;
  159. PCardinal = ^Cardinal;
  160. PQWord = ^QWord;
  161. PInt64 = ^Int64;
  162. PPointer = ^Pointer;
  163. PPPointer = ^PPointer;
  164. PBoolean = ^Boolean;
  165. PWordBool = ^WordBool;
  166. PLongBool = ^LongBool;
  167. PShortString = ^ShortString;
  168. PAnsiString = ^AnsiString;
  169. PDate = ^TDateTime;
  170. PError = ^Error;
  171. {$ifdef HASVARIANT}
  172. PVariant = ^Variant;
  173. {$endif HASVARIANT}
  174. {$ifdef HASWIDECHAR}
  175. PWideChar = ^WideChar;
  176. PPWideChar = ^PWideChar;
  177. { 1.0.x also has HASWIDECHAR defined, but doesn't support it
  178. fully, setting WChar to Word as fallback (PFV) }
  179. {$ifndef VER1_0}
  180. WChar = Widechar;
  181. {$else}
  182. WChar = Word;
  183. {$endif}
  184. {$else}
  185. WChar = Word;
  186. {$endif HASWIDECHAR}
  187. {$ifdef HASWIDESTRING}
  188. PWideString = ^WideString;
  189. {$endif HASWIDESTRING}
  190. TTextLineBreakStyle = (tlbsLF,tlbsCRLF,tlbsCR);
  191. { procedure type }
  192. TProcedure = Procedure;
  193. const
  194. { Maximum value of the biggest signed and unsigned integer type available}
  195. MaxSIntValue = High(ValSInt);
  196. MaxUIntValue = High(ValUInt);
  197. { max. values for longint and int}
  198. maxLongint = $7fffffff;
  199. maxSmallint = 32767;
  200. maxint = maxsmallint;
  201. type
  202. IntegerArray = array[0..$effffff] of Integer;
  203. PIntegerArray = ^IntegerArray;
  204. PointerArray = array [0..512*1024*1024 - 2] of Pointer;
  205. PPointerArray = ^PointerArray;
  206. {$ifndef VER1_0}
  207. TBoundArray = array of Integer;
  208. {$endif VER1_0}
  209. TPCharArray = packed array[0..(MaxLongint div SizeOf(PChar))-1] of PChar;
  210. PPCharArray = ^TPCharArray;
  211. const
  212. {$ifdef i386}
  213. Test8086 : byte = 2; { Always i386 or newer }
  214. Test8087 : byte = 3; { Always 387 or newer. Emulated if needed. }
  215. {$endif i386}
  216. {$ifdef m68k}
  217. Test68000 : byte = 0; { Must be determined at startup for both }
  218. Test68881 : byte = 0;
  219. {$endif}
  220. { max level in dumping on error }
  221. Max_Frame_Dump : Word = 8;
  222. { Exit Procedure handling consts and types }
  223. ExitProc : pointer = nil;
  224. Erroraddr: pointer = nil;
  225. Errorcode: Word = 0;
  226. { file input modes }
  227. fmClosed = $D7B0;
  228. fmInput = $D7B1;
  229. fmOutput = $D7B2;
  230. fmInOut = $D7B3;
  231. fmAppend = $D7B4;
  232. Filemode : byte = 2;
  233. CmdLine : PChar = nil;
  234. { assume that this program will not spawn other threads, when the
  235. first thread is started the following constants need to be filled }
  236. IsMultiThread : boolean = FALSE;
  237. { Indicates if there was an error }
  238. StackError : boolean = FALSE;
  239. var
  240. ExitCode : Word;
  241. RandSeed : Cardinal;
  242. { Delphi compatibility }
  243. IsLibrary : boolean;
  244. IsConsole : boolean;
  245. { Threading support }
  246. fpc_threadvar_relocate_proc : pointer; public name 'FPC_THREADVAR_RELOCATE';
  247. {$ifdef SUPPORT_THREADVAR}
  248. ThreadVar
  249. {$else SUPPORT_THREADVAR}
  250. Var
  251. {$endif SUPPORT_THREADVAR}
  252. { Standard In- and Output }
  253. Output,
  254. Input,
  255. StdOut,
  256. StdErr : Text;
  257. InOutRes : Word;
  258. { Stack checking }
  259. StackBottom,
  260. StackLength : Cardinal;
  261. {****************************************************************************
  262. Processor specific routines
  263. ****************************************************************************}
  264. Procedure Move(const source;var dest;count:Longint);
  265. Procedure FillChar(Var x;count:Longint;Value:Boolean);{$ifdef SYSTEMINLINE}inline;{$endif}
  266. Procedure FillChar(Var x;count:Longint;Value:Char);{$ifdef SYSTEMINLINE}inline;{$endif}
  267. Procedure FillChar(Var x;count:Longint;Value:Byte);
  268. procedure FillByte(var x;count:longint;value:byte);
  269. Procedure FillWord(Var x;count:Longint;Value:Word);
  270. procedure FillDWord(var x;count:longint;value:DWord);
  271. function IndexChar(const buf;len:longint;b:char):longint;
  272. function IndexByte(const buf;len:longint;b:byte):longint;
  273. function Indexword(const buf;len:longint;b:word):longint;
  274. function IndexDWord(const buf;len:longint;b:DWord):longint;
  275. function CompareChar(const buf1,buf2;len:longint):longint;
  276. function CompareByte(const buf1,buf2;len:longint):longint;
  277. function CompareWord(const buf1,buf2;len:longint):longint;
  278. function CompareDWord(const buf1,buf2;len:longint):longint;
  279. procedure MoveChar0(const buf1;var buf2;len:longint);
  280. function IndexChar0(const buf;len:longint;b:char):longint;
  281. function CompareChar0(const buf1,buf2;len:longint):longint;
  282. {****************************************************************************
  283. Math Routines
  284. ****************************************************************************}
  285. Function lo(w:Word):byte;
  286. Function lo(l:Longint):Word;
  287. Function lo(l:DWord):Word;
  288. Function lo(i:Integer):byte;
  289. Function lo(B: Byte):Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
  290. Function hi(w:Word):byte;
  291. Function hi(i:Integer):byte;
  292. Function hi(l:Longint):Word;
  293. Function hi(b : Byte) : Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
  294. Function hi(l: DWord): Word;
  295. Function lo(q : QWord) : DWord;
  296. Function lo(i : Int64) : DWord;
  297. Function hi(q : QWord) : DWord;
  298. Function hi(i : Int64) : DWord;
  299. Function Swap (X:Word):Word;{$ifdef SYSTEMINLINE}inline;{$endif}
  300. Function Swap (X:Integer):Integer;{$ifdef SYSTEMINLINE}inline;{$endif}
  301. Function Swap (X:Cardinal):Cardinal;{$ifdef SYSTEMINLINE}inline;{$endif}
  302. Function Swap (X:LongInt):LongInt;{$ifdef SYSTEMINLINE}inline;{$endif}
  303. Function Swap (X:QWord):QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
  304. Function Swap (X:Int64):Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
  305. Function Random(l:cardinal):cardinal;
  306. Function Random(l:longint):longint;
  307. Function Random: extended;
  308. Procedure Randomize;
  309. Function abs(l:Longint):Longint;{$ifdef SYSTEMINLINE}inline;{$endif}
  310. Function abs(l:Int64):Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
  311. Function sqr(l:Longint):Longint;{$ifdef SYSTEMINLINE}inline;{$endif}
  312. Function sqr(l:Int64):Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
  313. Function sqr(l:QWord):QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
  314. Function odd(l:Longint):Boolean;{$ifdef SYSTEMINLINE}inline;{$endif}
  315. Function odd(l:Longword):Boolean;{$ifdef SYSTEMINLINE}inline;{$endif}
  316. Function odd(l:Int64):Boolean;{$ifdef SYSTEMINLINE}inline;{$endif}
  317. Function odd(l:QWord):Boolean;{$ifdef SYSTEMINLINE}inline;{$endif}
  318. { float math routines }
  319. {$I mathh.inc}
  320. {****************************************************************************
  321. Addr/Pointer Handling
  322. ****************************************************************************}
  323. Function ptr(sel,off:Longint):farpointer;{$ifdef SYSTEMINLINE}inline;{$endif}
  324. Function Cseg:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
  325. Function Dseg:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
  326. Function Sseg:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
  327. {****************************************************************************
  328. PChar and String Handling
  329. ****************************************************************************}
  330. function strpas(p:pchar):shortstring;
  331. function strlen(p:pchar):longint;
  332. { Shortstring functions }
  333. {$ifndef INTERNSETLENGTH}
  334. Procedure SetLength (Var S:ShortString;len:StrLenInt);
  335. {$endif INTERNSETLENGTH}
  336. {$ifndef InternCopy}
  337. Function Copy(const s:shortstring;index:StrLenInt;count:StrLenInt):shortstring;
  338. {$endif interncopy}
  339. Procedure Delete(Var s:shortstring;index:StrLenInt;count:StrLenInt);
  340. Procedure Insert(const source:shortstring;Var s:shortstring;index:StrLenInt);
  341. Procedure Insert(source:Char;Var s:shortstring;index:StrLenInt);
  342. Function Pos(const substr:shortstring;const s:shortstring):StrLenInt;
  343. Function Pos(C:Char;const s:shortstring):StrLenInt;
  344. Procedure SetString (Var S : Shortstring; Buf : PChar; Len : Longint);
  345. Procedure SetString (Var S : AnsiString; Buf : PChar; Len : Longint);
  346. {$ifndef INTERNLENGTH}
  347. Function Length(s:string):byte;
  348. {$endif INTERNLENGTH}
  349. Function upCase(const s:shortstring):shortstring;
  350. Function lowerCase(const s:shortstring):shortstring; overload;
  351. Function Space(b:byte):shortstring;
  352. Function hexStr(Val:Longint;cnt:byte):shortstring;
  353. Function OctStr(Val:Longint;cnt:byte):shortstring;
  354. Function binStr(Val:Longint;cnt:byte):shortstring;
  355. Function hexStr(Val:int64;cnt:byte):shortstring;
  356. Function OctStr(Val:int64;cnt:byte):shortstring;
  357. Function binStr(Val:int64;cnt:byte):shortstring;
  358. { Char functions }
  359. Function Chr(b:byte):Char;
  360. Function upCase(c:Char):Char;
  361. Function lowerCase(c:Char):Char; overload;
  362. {$ifndef InternCopy}
  363. function copy(c:char;index : StrLenInt;count : StrLenInt): shortstring;
  364. {$endif interncopy}
  365. function pos(const substr : shortstring;c:char): StrLenInt;
  366. {$ifndef INTERNLENGTH}
  367. function length(c:char):byte;
  368. {$endif INTERNLENGTH}
  369. {****************************************************************************
  370. AnsiString Handling
  371. ****************************************************************************}
  372. {$ifndef INTERNSETLENGTH}
  373. Procedure SetLength (Var S : AnsiString; l : Longint);
  374. {$endif INTERNSETLENGTH}
  375. Procedure UniqueString (Var S : AnsiString);
  376. {$ifndef INTERNLENGTH}
  377. Function Length (Const S : AnsiString) : Longint;
  378. {$endif INTERNLENGTH}
  379. {$ifndef InternCopy}
  380. Function Copy (Const S : AnsiString; Index,Size : Longint) : AnsiString;
  381. {$endif interncopy}
  382. Function Pos (Const Substr : AnsiString; Const Source : AnsiString) : Longint;
  383. Function Pos (c : Char; Const s : AnsiString) : Longint;
  384. Procedure Insert (Const Source : AnsiString; Var S : AnsiString; Index : Longint);
  385. Procedure Delete (Var S : AnsiString; Index,Size: Longint);
  386. Function StringOfChar(c : char;l : longint) : AnsiString;
  387. function upcase(const s : ansistring) : ansistring;
  388. function lowercase(const s : ansistring) : ansistring;
  389. {****************************************************************************
  390. WideString Handling
  391. ****************************************************************************}
  392. {$ifdef HASWIDESTRING}
  393. {$ifndef INTERNSETLENGTH}
  394. Procedure SetLength (Var S : WideString; l : Longint);
  395. {$endif INTERNSETLENGTH}
  396. Procedure UniqueString (Var S : WideString);
  397. {$ifndef INTERNLENGTH}
  398. Function Length (Const S : WideString) : Longint;
  399. {$endif INTERNLENGTH}
  400. {$ifndef InternCopy}
  401. Function Copy (Const S : WideString; Index,Size : Longint) : WideString;
  402. {$endif interncopy}
  403. Function Pos (Const Substr : WideString; Const Source : WideString) : Longint;
  404. Function Pos (c : Char; Const s : WideString) : Longint;
  405. Function Pos (c : WideChar; Const s : WideString) : Longint;
  406. Procedure Insert (Const Source : WideString; Var S : WideString; Index : Longint);
  407. Procedure Delete (Var S : WideString; Index,Size: Longint);
  408. Procedure SetString (Var S : WideString; Buf : PWideChar; Len : Longint);
  409. Procedure SetString (Var S : WideString; Buf : PChar; Len : Longint);
  410. function WideCharToString(S : PWideChar) : AnsiString;
  411. function StringToWideChar(const Src : AnsiString;Dest : PWideChar;DestSize : LongInt) : PWideChar;
  412. function WideCharLenToString(S : PWideChar;Len : LongInt) : AnsiString;
  413. procedure WideCharLenToStrVar(Src : PWideChar;Len : LongInt;var Dest : AnsiString);
  414. procedure WideCharToStrVar(S : PWideChar;var Dest : AnsiString);
  415. {$endif HASWIDESTRING}
  416. {****************************************************************************
  417. Untyped File Management
  418. ****************************************************************************}
  419. Procedure Assign(Var f:File;const Name:string);
  420. Procedure Assign(Var f:File;p:pchar);
  421. Procedure Assign(Var f:File;c:char);
  422. Procedure Rewrite(Var f:File;l:Longint);
  423. Procedure Rewrite(Var f:File);
  424. Procedure Reset(Var f:File;l:Longint);
  425. Procedure Reset(Var f:File);
  426. Procedure Close(Var f:File);
  427. Procedure BlockWrite(Var f:File;Const Buf;Count:Longint;Var Result:Longint);
  428. Procedure BlockWrite(Var f:File;Const Buf;Count:Cardinal;var Result:Cardinal);
  429. Procedure BlockWrite(Var f:File;Const Buf;Count:Word;Var Result:Word);
  430. Procedure BlockWrite(Var f:File;Const Buf;Count:Word;Var Result:Integer);
  431. Procedure BlockWrite(Var f:File;Const Buf;Count:Longint);
  432. Procedure BlockRead(Var f:File;Var Buf;count:Longint;Var Result:Longint);
  433. Procedure BlockRead(Var f:File;Var Buf;count:Cardinal;Var Result:Cardinal);
  434. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Word);
  435. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Integer);
  436. Procedure BlockRead(Var f:File;Var Buf;count:Longint);
  437. Function FilePos(Var f:File):Longint;
  438. Function FileSize(Var f:File):Longint;
  439. Procedure Seek(Var f:File;Pos:Longint);
  440. Function EOF(Var f:File):Boolean;
  441. Procedure Erase(Var f:File);
  442. Procedure Rename(Var f:File;const s:string);
  443. Procedure Rename(Var f:File;p:pchar);
  444. Procedure Rename(Var f:File;c:char);
  445. Procedure Truncate (Var F:File);
  446. {****************************************************************************
  447. Typed File Management
  448. ****************************************************************************}
  449. Procedure Assign(Var f:TypedFile;const Name:string);
  450. Procedure Assign(Var f:TypedFile;p:pchar);
  451. Procedure Assign(Var f:TypedFile;c:char);
  452. Procedure Rewrite(Var f:TypedFile);
  453. Procedure Reset(Var f:TypedFile);
  454. {****************************************************************************
  455. Text File Management
  456. ****************************************************************************}
  457. Procedure Assign(Var t:Text;const s:string);
  458. Procedure Assign(Var t:Text;p:pchar);
  459. Procedure Assign(Var t:Text;c:char);
  460. Procedure Close(Var t:Text);
  461. Procedure Rewrite(Var t:Text);
  462. Procedure Reset(Var t:Text);
  463. Procedure Append(Var t:Text);
  464. Procedure Flush(Var t:Text);
  465. Procedure Erase(Var t:Text);
  466. Procedure Rename(Var t:Text;const s:string);
  467. Procedure Rename(Var t:Text;p:pchar);
  468. Procedure Rename(Var t:Text;c:char);
  469. Function EOF(Var t:Text):Boolean;
  470. Function EOF:Boolean;
  471. Function EOLn(Var t:Text):Boolean;
  472. Function EOLn:Boolean;
  473. Function SeekEOLn (Var t:Text):Boolean;
  474. Function SeekEOF (Var t:Text):Boolean;
  475. Function SeekEOLn:Boolean;
  476. Function SeekEOF:Boolean;
  477. Procedure SetTextBuf(Var f:Text; Var Buf);
  478. Procedure SetTextBuf(Var f:Text; Var Buf; Size:Longint);
  479. {****************************************************************************
  480. Directory Management
  481. ****************************************************************************}
  482. Procedure chdir(const s:string);
  483. Procedure mkdir(const s:string);
  484. Procedure rmdir(const s:string);
  485. Procedure getdir(drivenr:byte;Var dir:shortstring);
  486. Procedure getdir(drivenr:byte;Var dir:ansistring);
  487. {*****************************************************************************
  488. Miscelleaous
  489. *****************************************************************************}
  490. { os independent calls to allow backtraces }
  491. function get_frame:longint;{$ifdef SYSTEMINLINE}inline;{$endif}
  492. function get_caller_addr(framebp:longint):longint;{$ifdef SYSTEMINLINE}inline;{$endif}
  493. function get_caller_frame(framebp:longint):longint;{$ifdef SYSTEMINLINE}inline;{$endif}
  494. Function IOResult:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
  495. Function Sptr:Longint;{$ifdef SYSTEMINLINE}inline;{$endif}
  496. {*****************************************************************************
  497. Init / Exit / ExitProc
  498. *****************************************************************************}
  499. Function Paramcount:Longint;
  500. Function ParamStr(l:Longint):string;
  501. Procedure Dump_Stack(var f : text;bp:Longint);
  502. Procedure RunError(w:Word);
  503. Procedure RunError;{$ifdef SYSTEMINLINE}inline;{$endif}
  504. Procedure halt(errnum:byte);
  505. Procedure AddExitProc(Proc:TProcedure);
  506. Procedure halt;{$ifdef SYSTEMINLINE}inline;{$endif}
  507. { Need to be exported for threads unit }
  508. Procedure SysInitExceptions;
  509. procedure SysInitStdIO;
  510. Procedure SysResetFPU;
  511. {*****************************************************************************
  512. Abstract/Assert/Error Handling
  513. *****************************************************************************}
  514. procedure AbstractError;
  515. Function SysBackTraceStr(Addr: Longint): ShortString;
  516. Procedure SysAssert(Const Msg,FName:ShortString;LineNo,ErrorAddr:Longint);
  517. { Error handlers }
  518. Type
  519. TBackTraceStrFunc = Function (Addr: Longint): ShortString;
  520. TErrorProc = Procedure (ErrNo : Longint; Address,Frame : Pointer);
  521. TAbstractErrorProc = Procedure;
  522. TAssertErrorProc = Procedure(const msg,fname:ShortString;lineno,erroraddr:longint);
  523. const
  524. BackTraceStrFunc : TBackTraceStrFunc = @SysBackTraceStr;
  525. ErrorProc : TErrorProc = nil;
  526. AbstractErrorProc : TAbstractErrorProc = nil;
  527. AssertErrorProc : TAssertErrorProc = @SysAssert;
  528. {*****************************************************************************
  529. SetJmp/LongJmp
  530. *****************************************************************************}
  531. {$i setjumph.inc}
  532. {*****************************************************************************
  533. Object Pascal support
  534. *****************************************************************************}
  535. {$i objpash.inc}
  536. {*****************************************************************************
  537. Variant support
  538. *****************************************************************************}
  539. {$ifdef HASVARIANT}
  540. {$i varianth.inc}
  541. {$endif HASVARIANT}
  542. {*****************************************************************************
  543. Internal helper routines support
  544. *****************************************************************************}
  545. {$i dynarrh.inc}
  546. {$i compproc.inc}
  547. {
  548. $Log$
  549. Revision 1.62 2002-12-21 17:20:27 florian
  550. + some types for D6 compatibility added
  551. Revision 1.61 2002/12/15 22:33:12 peter
  552. * SetString(WideString,[PChar|PWideChar],Len) added
  553. Revision 1.60 2002/11/16 20:12:22 florian
  554. + sparc types added
  555. + UTF*/UCS* types added
  556. Revision 1.59 2002/10/14 19:39:17 peter
  557. * threads unit added for thread support
  558. Revision 1.58 2002/10/06 13:56:47 carl
  559. - remove stack checking for every target in system unit
  560. Revision 1.57 2002/10/02 18:21:51 peter
  561. * Copy() changed to internal function calling compilerprocs
  562. * FPC_SHORTSTR_COPY renamed to FPC_SHORTSTR_ASSIGN because of the
  563. new copy functions
  564. Revision 1.56 2002/09/28 21:18:02 florian
  565. * map comp to int64 for the powerpc
  566. Revision 1.55 2002/09/26 21:50:37 florian
  567. + some WideString<->AnsiString conversion functions added
  568. Revision 1.54 2002/09/07 21:20:50 carl
  569. * cardinal -> longword
  570. - remove FPUInt64 variable
  571. Revision 1.53 2002/09/07 15:07:46 peter
  572. * old logs removed and tabs fixed
  573. Revision 1.52 2002/08/19 19:34:02 peter
  574. * SYSTEMINLINE define that will add inline directives for small
  575. functions and wrappers. This will be defined automaticly when
  576. the compiler defines the HASINLINE directive
  577. Revision 1.51 2002/08/06 20:53:38 michael
  578. + Added support for octal strings (using &)
  579. Revision 1.50 2002/07/26 22:46:06 florian
  580. * interface of system unit for Linux/PowerPC compiles
  581. Revision 1.49 2002/07/26 21:29:03 florian
  582. + powerpc type support
  583. Revision 1.48 2002/07/04 20:40:09 florian
  584. + some x86-64 support added
  585. Revision 1.47 2002/07/01 16:29:05 peter
  586. * sLineBreak changed to normal constant like Kylix
  587. Revision 1.46 2002/06/02 10:49:30 marco
  588. * Renamefest supports_double for FreeBSD too
  589. Revision 1.45 2002/04/21 15:51:51 carl
  590. * StackError is now a typed constant
  591. + $S can be used under unix
  592. Revision 1.44 2002/04/12 17:35:24 carl
  593. - removed unused variable
  594. Revision 1.43 2002/01/25 17:41:05 peter
  595. * moved array types to objpas unit
  596. Revision 1.42 2002/01/25 17:39:35 peter
  597. * array types added
  598. Revision 1.41 2002/01/24 18:27:06 peter
  599. * lowercase() overloaded
  600. Revision 1.40 2002/01/24 12:33:53 jonas
  601. * adapted ranges of native types to int64 (e.g. high cardinal is no
  602. longer longint($ffffffff), but just $fffffff in psystem)
  603. * small additional fix in 64bit rangecheck code generation for 32 bit
  604. processors
  605. * adaption of ranges required the matching talgorithm used for selecting
  606. which overloaded procedure to call to be adapted. It should now always
  607. select the closest match for ordinal parameters.
  608. + inttostr(qword) in sysstr.inc/sysstrh.inc
  609. + abs(int64), sqr(int64), sqr(qword) in systemh.inc/generic.inc (previous
  610. fixes were required to be able to add them)
  611. * is_in_limit() moved from ncal to types unit, should always be used
  612. instead of direct comparisons of low/high values of orddefs because
  613. qword is a special case
  614. }