systemh.inc 26 KB

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