systemh.inc 28 KB

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