systemh.inc 29 KB

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