systemh.inc 27 KB

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