systemh.inc 29 KB

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