systemh.inc 27 KB

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