systemh.inc 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861
  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. Type
  442. TWide2AnsiMove=procedure(source:pwidechar;dest:pchar;len:longint);
  443. TAnsi2WideMove=procedure(source:pchar;dest:pwidechar;len:longint);
  444. TWideStringManager = record
  445. Wide2AnsiMove : TWide2AnsiMove;
  446. Ansi2WideMove : TAnsi2WideMove;
  447. end;
  448. Procedure GetWideStringManager (Var Manager : TWideStringManager);
  449. Procedure SetWideStringManager (Const New : TWideStringManager);
  450. Procedure SetWideStringManager (Const New : TWideStringManager; Var Old: TWideStringManager);
  451. {$endif HASWIDESTRING}
  452. {****************************************************************************
  453. Untyped File Management
  454. ****************************************************************************}
  455. Procedure Assign(Var f:File;const Name:string);
  456. Procedure Assign(Var f:File;p:pchar);
  457. Procedure Assign(Var f:File;c:char);
  458. Procedure Rewrite(Var f:File;l:Longint);
  459. Procedure Rewrite(Var f:File);
  460. Procedure Reset(Var f:File;l:Longint);
  461. Procedure Reset(Var f:File);
  462. Procedure Close(Var f:File);
  463. Procedure BlockWrite(Var f:File;Const Buf;Count:Longint;Var Result:Longint);
  464. Procedure BlockWrite(Var f:File;Const Buf;Count:Cardinal;var Result:Cardinal);
  465. Procedure BlockWrite(Var f:File;Const Buf;Count:Word;Var Result:Word);
  466. Procedure BlockWrite(Var f:File;Const Buf;Count:Word;Var Result:Integer);
  467. Procedure BlockWrite(Var f:File;Const Buf;Count:Longint);
  468. Procedure BlockRead(Var f:File;Var Buf;count:Longint;Var Result:Longint);
  469. Procedure BlockRead(Var f:File;Var Buf;count:Cardinal;Var Result:Cardinal);
  470. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Word);
  471. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Integer);
  472. Procedure BlockRead(Var f:File;Var Buf;count:Longint);
  473. Function FilePos(Var f:File):Longint;
  474. Function FileSize(Var f:File):Longint;
  475. Procedure Seek(Var f:File;Pos:Longint);
  476. Function EOF(Var f:File):Boolean;
  477. Procedure Erase(Var f:File);
  478. Procedure Rename(Var f:File;const s:string);
  479. Procedure Rename(Var f:File;p:pchar);
  480. Procedure Rename(Var f:File;c:char);
  481. Procedure Truncate (Var F:File);
  482. {****************************************************************************
  483. Typed File Management
  484. ****************************************************************************}
  485. Procedure Assign(Var f:TypedFile;const Name:string);
  486. Procedure Assign(Var f:TypedFile;p:pchar);
  487. Procedure Assign(Var f:TypedFile;c:char);
  488. Procedure Rewrite(Var f:TypedFile);
  489. Procedure Reset(Var f:TypedFile);
  490. {****************************************************************************
  491. Text File Management
  492. ****************************************************************************}
  493. Procedure Assign(Var t:Text;const s:string);
  494. Procedure Assign(Var t:Text;p:pchar);
  495. Procedure Assign(Var t:Text;c:char);
  496. Procedure Close(Var t:Text);
  497. Procedure Rewrite(Var t:Text);
  498. Procedure Reset(Var t:Text);
  499. Procedure Append(Var t:Text);
  500. Procedure Flush(Var t:Text);
  501. Procedure Erase(Var t:Text);
  502. Procedure Rename(Var t:Text;const s:string);
  503. Procedure Rename(Var t:Text;p:pchar);
  504. Procedure Rename(Var t:Text;c:char);
  505. Function EOF(Var t:Text):Boolean;
  506. Function EOF:Boolean;
  507. Function EOLn(Var t:Text):Boolean;
  508. Function EOLn:Boolean;
  509. Function SeekEOLn (Var t:Text):Boolean;
  510. Function SeekEOF (Var t:Text):Boolean;
  511. Function SeekEOLn:Boolean;
  512. Function SeekEOF:Boolean;
  513. Procedure SetTextBuf(Var f:Text; Var Buf);
  514. Procedure SetTextBuf(Var f:Text; Var Buf; Size:Longint);
  515. {****************************************************************************
  516. Directory Management
  517. ****************************************************************************}
  518. Procedure chdir(const s:string);
  519. Procedure mkdir(const s:string);
  520. Procedure rmdir(const s:string);
  521. Procedure getdir(drivenr:byte;Var dir:shortstring);
  522. Procedure getdir(drivenr:byte;Var dir:ansistring);
  523. {*****************************************************************************
  524. Miscelleaous
  525. *****************************************************************************}
  526. { os independent calls to allow backtraces }
  527. function get_frame:pointer;{$ifdef SYSTEMINLINE}inline;{$endif}
  528. function get_caller_addr(framebp:pointer):pointer;{$ifdef SYSTEMINLINE}inline;{$endif}
  529. function get_caller_frame(framebp:pointer):pointer;{$ifdef SYSTEMINLINE}inline;{$endif}
  530. Function IOResult:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
  531. Function Sptr:Pointer;{$ifdef SYSTEMINLINE}inline;{$endif}
  532. {*****************************************************************************
  533. Init / Exit / ExitProc
  534. *****************************************************************************}
  535. Function Paramcount:Longint;
  536. Function ParamStr(l:Longint):string;
  537. Procedure Dump_Stack(var f : text;bp:pointer);
  538. Procedure RunError(w:Word);
  539. Procedure RunError;{$ifdef SYSTEMINLINE}inline;{$endif}
  540. Procedure halt(errnum:byte);
  541. Procedure AddExitProc(Proc:TProcedure);
  542. Procedure halt;{$ifdef SYSTEMINLINE}inline;{$endif}
  543. { Need to be exported for threads unit }
  544. Procedure SysInitExceptions;
  545. procedure SysInitStdIO;
  546. Procedure SysResetFPU;
  547. {*****************************************************************************
  548. Abstract/Assert/Error Handling
  549. *****************************************************************************}
  550. procedure AbstractError;
  551. Function SysBackTraceStr(Addr:Pointer): ShortString;
  552. Procedure SysAssert(Const Msg,FName:ShortString;LineNo:Longint;ErrorAddr:Pointer);
  553. { Error handlers }
  554. Type
  555. TBackTraceStrFunc = Function (Addr: Pointer): ShortString;
  556. TErrorProc = Procedure (ErrNo : Longint; Address,Frame : Pointer);
  557. TAbstractErrorProc = Procedure;
  558. TAssertErrorProc = Procedure(const msg,fname:ShortString;lineno:longint;erroraddr:pointer);
  559. const
  560. BackTraceStrFunc : TBackTraceStrFunc = @SysBackTraceStr;
  561. ErrorProc : TErrorProc = nil;
  562. AbstractErrorProc : TAbstractErrorProc = nil;
  563. AssertErrorProc : TAssertErrorProc = @SysAssert;
  564. {*****************************************************************************
  565. SetJmp/LongJmp
  566. *****************************************************************************}
  567. {$i setjumph.inc}
  568. {*****************************************************************************
  569. Object Pascal support
  570. *****************************************************************************}
  571. {$i objpash.inc}
  572. {*****************************************************************************
  573. Variant support
  574. *****************************************************************************}
  575. {$ifdef HASVARIANT}
  576. {$i varianth.inc}
  577. {$endif HASVARIANT}
  578. {*****************************************************************************
  579. Internal helper routines support
  580. *****************************************************************************}
  581. {$i dynarrh.inc}
  582. {$i compproc.inc}
  583. {
  584. $Log$
  585. Revision 1.80 2003-11-29 17:27:05 michael
  586. + Added overloaded version of SetWideStringManager without old parameter
  587. Revision 1.79 2003/11/28 20:36:13 michael
  588. + Added WideStringManager
  589. Revision 1.78 2003/11/15 19:01:27 florian
  590. * fixed rtl to work with the integrated fpc ppc assembler reader
  591. Revision 1.77 2003/11/03 09:42:28 marco
  592. * Peter's Cardinal<->Longint fixes patch
  593. Revision 1.76 2003/10/17 20:52:12 olle
  594. * Changed m68k to cpum68k, i386 to cpui386
  595. Revision 1.75 2003/10/16 15:43:13 peter
  596. * THandle is platform dependent
  597. Revision 1.74 2003/10/08 16:24:47 florian
  598. * fixed some variant issues
  599. * improved type declarations
  600. Revision 1.72 2003/09/04 16:07:31 florian
  601. * fixed qword_to_double conversion on powerpc
  602. Revision 1.71 2003/09/03 14:09:37 florian
  603. * arm fixes to the common rtl code
  604. * some generic math code fixed
  605. * ...
  606. Revision 1.70 2003/09/01 20:47:23 peter
  607. * pcomp added for sparc
  608. Revision 1.69 2003/05/01 08:05:23 florian
  609. * started to make the rtl 64 bit save by introducing SizeInt and SizeUInt (similar to size_t of C)
  610. Revision 1.68 2003/04/30 16:36:39 florian
  611. + support for generic pchar routines added
  612. + some basic rtl stuff for x86-64 added
  613. Revision 1.67 2003/04/25 21:09:44 peter
  614. * remove dos lf
  615. Revision 1.66 2003/04/23 22:46:41 florian
  616. + powerpc defines now pcomp as well
  617. Revision 1.65 2003/04/01 15:36:31 peter
  618. * make HResult unique type
  619. Revision 1.64 2003/03/17 14:30:11 peter
  620. * changed address parameter/return values to pointer instead
  621. of longint
  622. Revision 1.63 2003/01/13 14:37:11 florian
  623. * cpu defines fixed
  624. * ... = type ...; stuff reactived, should work now with 1.1
  625. Revision 1.62 2002/12/21 17:20:27 florian
  626. + some types for D6 compatibility added
  627. Revision 1.61 2002/12/15 22:33:12 peter
  628. * SetString(WideString,[PChar|PWideChar],Len) added
  629. Revision 1.60 2002/11/16 20:12:22 florian
  630. + sparc types added
  631. + UTF*/UCS* types added
  632. Revision 1.59 2002/10/14 19:39:17 peter
  633. * threads unit added for thread support
  634. Revision 1.58 2002/10/06 13:56:47 carl
  635. - remove stack checking for every target in system unit
  636. Revision 1.57 2002/10/02 18:21:51 peter
  637. * Copy() changed to internal function calling compilerprocs
  638. * FPC_SHORTSTR_COPY renamed to FPC_SHORTSTR_ASSIGN because of the
  639. new copy functions
  640. Revision 1.56 2002/09/28 21:18:02 florian
  641. * map comp to int64 for the powerpc
  642. Revision 1.55 2002/09/26 21:50:37 florian
  643. + some WideString<->AnsiString conversion functions added
  644. Revision 1.54 2002/09/07 21:20:50 carl
  645. * cardinal -> longword
  646. - remove FPUInt64 variable
  647. Revision 1.53 2002/09/07 15:07:46 peter
  648. * old logs removed and tabs fixed
  649. Revision 1.52 2002/08/19 19:34:02 peter
  650. * SYSTEMINLINE define that will add inline directives for small
  651. functions and wrappers. This will be defined automaticly when
  652. the compiler defines the HASINLINE directive
  653. Revision 1.51 2002/08/06 20:53:38 michael
  654. + Added support for octal strings (using &)
  655. Revision 1.50 2002/07/26 22:46:06 florian
  656. * interface of system unit for Linux/PowerPC compiles
  657. Revision 1.49 2002/07/26 21:29:03 florian
  658. + powerpc type support
  659. Revision 1.48 2002/07/04 20:40:09 florian
  660. + some x86-64 support added
  661. Revision 1.47 2002/07/01 16:29:05 peter
  662. * sLineBreak changed to normal constant like Kylix
  663. Revision 1.46 2002/06/02 10:49:30 marco
  664. * Renamefest supports_double for FreeBSD too
  665. Revision 1.45 2002/04/21 15:51:51 carl
  666. * StackError is now a typed constant
  667. + $S can be used under unix
  668. Revision 1.44 2002/04/12 17:35:24 carl
  669. - removed unused variable
  670. Revision 1.43 2002/01/25 17:41:05 peter
  671. * moved array types to objpas unit
  672. Revision 1.42 2002/01/25 17:39:35 peter
  673. * array types added
  674. Revision 1.41 2002/01/24 18:27:06 peter
  675. * lowercase() overloaded
  676. Revision 1.40 2002/01/24 12:33:53 jonas
  677. * adapted ranges of native types to int64 (e.g. high cardinal is no
  678. longer longint($ffffffff), but just $fffffff in psystem)
  679. * small additional fix in 64bit rangecheck code generation for 32 bit
  680. processors
  681. * adaption of ranges required the matching talgorithm used for selecting
  682. which overloaded procedure to call to be adapted. It should now always
  683. select the closest match for ordinal parameters.
  684. + inttostr(qword) in sysstr.inc/sysstrh.inc
  685. + abs(int64), sqr(int64), sqr(qword) in systemh.inc/generic.inc (previous
  686. fixes were required to be able to add them)
  687. * is_in_limit() moved from ncal to types unit, should always be used
  688. instead of direct comparisons of low/high values of orddefs because
  689. qword is a special case
  690. }