systemh.inc 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. {
  2. This file is part of the Free Pascal Run time library.
  3. Copyright (c) 1999-2000 by the Free Pascal development team
  4. This File contains the OS independent declarations of the system unit
  5. See the File COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {****************************************************************************
  12. Needed switches
  13. ****************************************************************************}
  14. {$I-,Q-,H-,R-,V-}
  15. {$mode objfpc}
  16. { Using inlining for small system functions/wrappers }
  17. {$ifdef HASINLINE}
  18. {$inline on}
  19. {$define SYSTEMINLINE}
  20. {$endif}
  21. { Use threadvars when the compiler supports it }
  22. { don't use FPU registervariables on the i386 }
  23. {$ifdef CPUI386}
  24. {$maxfpuregisters 0}
  25. {$endif CPUI386}
  26. { the assembler helpers need this }
  27. {$ifdef POWERPC}
  28. {$goto+}
  29. {$endif POWERPC}
  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. { The compiler has all integer types defined internally. Here
  45. we define only aliases }
  46. DWord = LongWord;
  47. Cardinal = LongWord;
  48. Integer = SmallInt;
  49. {$ifdef CPUI386}
  50. { for bootstrapping with 1.0.x }
  51. {$define CPU32}
  52. {$define DEFAULT_EXTENDED}
  53. {$define SUPPORT_SINGLE}
  54. {$define SUPPORT_DOUBLE}
  55. {$define SUPPORT_EXTENDED}
  56. {$define SUPPORT_COMP}
  57. ValReal = Extended;
  58. {$endif CPUI386}
  59. {$ifdef CPUX86_64}
  60. {$define DEFAULT_EXTENDED}
  61. {$define SUPPORT_SINGLE}
  62. {$define SUPPORT_DOUBLE}
  63. {$define SUPPORT_EXTENDED}
  64. {$define SUPPORT_COMP}
  65. ValReal = Extended;
  66. {$endif CPUX86_64}
  67. {$ifdef CPUM68K}
  68. ValReal = Real;
  69. {$define SUPPORT_SINGLE}
  70. {$IFDEF Unix}
  71. { Linux FPU emulator will be used }
  72. {$define SUPPORT_DOUBLE}
  73. {$ENDIF}
  74. {$IFOPT E-}
  75. { If not compiling with emulation }
  76. { then support double type. }
  77. {$define SUPPORT_DOUBLE}
  78. {$ENDIF}
  79. { Comp type does not exist on fpu }
  80. Comp = int64;
  81. PComp = ^Comp;
  82. FarPointer = Pointer;
  83. {$endif CPUM68K}
  84. {$ifdef CPUPOWERPC}
  85. {$define DEFAULT_DOUBLE}
  86. {$define SUPPORT_SINGLE}
  87. {$define SUPPORT_DOUBLE}
  88. {$define FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE}
  89. ValReal = Double;
  90. { map comp to int64, but this doesn't mean we compile the comp support in! }
  91. Comp = Int64;
  92. PComp = ^Comp;
  93. FarPointer = Pointer;
  94. {$endif CPUPOWERPC}
  95. {$ifdef CPUSPARC}
  96. {$define DEFAULT_DOUBLE}
  97. {$define SUPPORT_SINGLE}
  98. {$define SUPPORT_DOUBLE}
  99. {$define FPC_INCLUDE_SOFTWARE_SHIFT_INT64}
  100. ValReal = Double;
  101. { map comp to int64, but this doesn't mean we compile the comp support in! }
  102. Comp = Int64;
  103. PComp = ^Comp;
  104. FarPointer = Pointer;
  105. {$endif CPUSPARC}
  106. {$ifdef CPUARM}
  107. {$define DEFAULT_DOUBLE}
  108. {$define SUPPORT_SINGLE}
  109. {$define SUPPORT_DOUBLE}
  110. {$define FPC_INCLUDE_SOFTWARE_MOD_DIV}
  111. {$define FPC_INCLUDE_SOFTWARE_SHIFT_INT64}
  112. {$define FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE}
  113. ValReal = Real;
  114. { map comp to int64, but this doesn't mean we compile the comp support in! }
  115. Comp = Int64;
  116. PComp = ^Comp;
  117. FarPointer = Pointer;
  118. {$endif CPUARM}
  119. {$ifdef CPU64}
  120. SizeInt = Int64;
  121. SizeUInt = QWord;
  122. PtrInt = Int64;
  123. PtrUInt = QWord;
  124. ValSInt = int64;
  125. ValUInt = qword;
  126. {$endif CPU64}
  127. {$ifdef CPU32}
  128. SizeInt = Longint;
  129. SizeUInt = DWord;
  130. PtrInt = Longint;
  131. PtrUInt = DWord;
  132. ValSInt = Longint;
  133. ValUInt = Cardinal;
  134. {$endif CPU32}
  135. { Zero - terminated strings }
  136. PChar = ^Char;
  137. PPChar = ^PChar;
  138. { AnsiChar is equivalent of Char, so we need
  139. to use type renamings }
  140. TAnsiChar = Char;
  141. AnsiChar = Char;
  142. PAnsiChar = PChar;
  143. PPAnsiChar = PPChar;
  144. UCS4Char = type LongWord;
  145. PUCS4Char = ^UCS4Char;
  146. TUCS4CharArray = array[0..$effffff] of UCS4Char;
  147. PUCS4CharArray = ^TUCS4CharArray;
  148. UCS4String = array of UCS4Char;
  149. UTF8String = type ansistring;
  150. PUTF8String = ^UTF8String;
  151. HRESULT = type Longint;
  152. TDateTime = type Double;
  153. Error = type Longint;
  154. PSingle = ^Single;
  155. PDouble = ^Double;
  156. PCurrency = ^Currency;
  157. {$ifdef SUPPORT_COMP}
  158. PComp = ^Comp;
  159. {$endif SUPPORT_COMP}
  160. PExtended = ^Extended;
  161. PSmallInt = ^Smallint;
  162. PShortInt = ^Shortint;
  163. PInteger = ^Integer;
  164. PByte = ^Byte;
  165. PWord = ^word;
  166. PDWord = ^DWord;
  167. PLongWord = ^LongWord;
  168. PLongint = ^Longint;
  169. PCardinal = ^Cardinal;
  170. PQWord = ^QWord;
  171. PInt64 = ^Int64;
  172. PPtrInt = ^PtrInt;
  173. PSizeInt = ^SizeInt;
  174. PPointer = ^Pointer;
  175. PPPointer = ^PPointer;
  176. PBoolean = ^Boolean;
  177. PWordBool = ^WordBool;
  178. PLongBool = ^LongBool;
  179. PShortString = ^ShortString;
  180. PAnsiString = ^AnsiString;
  181. PDate = ^TDateTime;
  182. PError = ^Error;
  183. PVariant = ^Variant;
  184. POleVariant = ^OleVariant;
  185. PWideChar = ^WideChar;
  186. PPWideChar = ^PWideChar;
  187. WChar = Widechar;
  188. UCS2Char = WideChar;
  189. PUCS2Char = PWideChar;
  190. PWideString = ^WideString;
  191. { Needed for fpc_get_output }
  192. PText = ^Text;
  193. TTextLineBreakStyle = (tlbsLF,tlbsCRLF,tlbsCR);
  194. { procedure type }
  195. TProcedure = Procedure;
  196. { platform dependent types }
  197. {$i sysosh.inc}
  198. const
  199. { Maximum value of the biggest signed and unsigned integer type available}
  200. MaxSIntValue = High(ValSInt);
  201. MaxUIntValue = High(ValUInt);
  202. { max. values for longint and int}
  203. maxLongint = $7fffffff;
  204. maxSmallint = 32767;
  205. maxint = maxsmallint;
  206. type
  207. IntegerArray = array[0..$effffff] of Integer;
  208. PIntegerArray = ^IntegerArray;
  209. PointerArray = array [0..512*1024*1024 - 2] of Pointer;
  210. PPointerArray = ^PointerArray;
  211. TBoundArray = array of Integer;
  212. TPCharArray = packed array[0..(MaxLongint div SizeOf(PChar))-1] of PChar;
  213. PPCharArray = ^TPCharArray;
  214. const
  215. {$ifdef cpui386}
  216. Test8086 : byte = 2; { Always i386 or newer }
  217. Test8087 : byte = 3; { Always 387 or newer. Emulated if needed. }
  218. {$endif cpui386}
  219. {$ifdef cpum68k}
  220. Test68000 : byte = 0; { Must be determined at startup for both }
  221. Test68881 : byte = 0;
  222. {$endif cpum68k}
  223. { max level in dumping on error }
  224. Max_Frame_Dump : Word = 8;
  225. { Exit Procedure handling consts and types }
  226. ExitProc : pointer = nil;
  227. Erroraddr: pointer = nil;
  228. Errorcode: Word = 0;
  229. { file input modes }
  230. fmClosed = $D7B0;
  231. fmInput = $D7B1;
  232. fmOutput = $D7B2;
  233. fmInOut = $D7B3;
  234. fmAppend = $D7B4;
  235. Filemode : byte = 2;
  236. CmdLine : PChar = nil;
  237. (* Value should be changed during system initialization as appropriate. *)
  238. { assume that this program will not spawn other threads, when the
  239. first thread is started the following constants need to be filled }
  240. IsMultiThread : boolean = FALSE;
  241. { set to true, if a threading helper is used before a thread
  242. manager has been installed }
  243. ThreadingAlreadyUsed : boolean = FALSE;
  244. { Indicates if there was an error }
  245. StackError : boolean = FALSE;
  246. InitProc : Pointer = nil;
  247. var
  248. ExitCode : Word; public name 'operatingsystem_result';
  249. RandSeed : Cardinal;
  250. { Delphi compatibility }
  251. IsLibrary : boolean;
  252. IsConsole : boolean;
  253. { Threading support }
  254. fpc_threadvar_relocate_proc : pointer; public name 'FPC_THREADVAR_RELOCATE';
  255. ThreadVar
  256. ThreadID : TThreadID;
  257. { Standard In- and Output }
  258. ErrOutput,
  259. Output,
  260. Input,
  261. StdOut,
  262. StdErr : Text;
  263. InOutRes : Word;
  264. { Stack checking }
  265. StackBottom : Pointer;
  266. StackLength : Cardinal;
  267. { Numbers for routines that have compiler magic }
  268. {$I innr.inc}
  269. {****************************************************************************
  270. Processor specific routines
  271. ****************************************************************************}
  272. {$ifdef FPC_USE_LIBC}
  273. {$ifdef SYSTEMINLINE}
  274. {$define INLINEGENERICS}
  275. {$endif}
  276. {$endif}
  277. Procedure Move(const source;var dest;count:SizeInt);{$ifdef INLINEGENERICS}inline;{$endif}
  278. Procedure FillChar(Var x;count:SizeInt;Value:Boolean);{$ifdef SYSTEMINLINE}inline;{$endif}
  279. Procedure FillChar(Var x;count:SizeInt;Value:Char);{$ifdef SYSTEMINLINE}inline;{$endif}
  280. Procedure FillChar(Var x;count:SizeInt;Value:Byte);{$ifdef INLINEGENERICS}inline;{$endif}
  281. procedure FillByte(var x;count:SizeInt;value:byte);{$ifdef INLINEGENERICS}inline;{$endif}
  282. Procedure FillWord(Var x;count:SizeInt;Value:Word);
  283. procedure FillDWord(var x;count:SizeInt;value:DWord);
  284. function IndexChar(const buf;len:SizeInt;b:char):SizeInt;
  285. function IndexByte(const buf;len:SizeInt;b:byte):SizeInt;{$ifdef INLINEGENERICS}inline;{$endif}
  286. function Indexword(const buf;len:SizeInt;b:word):SizeInt;
  287. function IndexDWord(const buf;len:SizeInt;b:DWord):SizeInt;
  288. function CompareChar(const buf1,buf2;len:SizeInt):SizeInt;
  289. function CompareByte(const buf1,buf2;len:SizeInt):SizeInt;{$ifdef INLINEGENERICS}inline;{$endif}
  290. function CompareWord(const buf1,buf2;len:SizeInt):SizeInt;
  291. function CompareDWord(const buf1,buf2;len:SizeInt):SizeInt;
  292. procedure MoveChar0(const buf1;var buf2;len:SizeInt);
  293. function IndexChar0(const buf;len:SizeInt;b:char):SizeInt;
  294. function CompareChar0(const buf1,buf2;len:SizeInt):SizeInt;{$ifdef INLINEGENERICS}inline;{$endif}
  295. procedure prefetch(const mem);[internproc:fpc_in_prefetch_var];
  296. {****************************************************************************
  297. Math Routines
  298. ****************************************************************************}
  299. Function lo(B: Byte):Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
  300. Function hi(b : Byte) : Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
  301. Function lo(i : Integer) : byte; [INTERNPROC: fpc_in_lo_Word];
  302. Function lo(w : Word) : byte; [INTERNPROC: fpc_in_lo_Word];
  303. Function lo(l : Longint) : Word; [INTERNPROC: fpc_in_lo_long];
  304. Function lo(l : DWord) : Word; [INTERNPROC: fpc_in_lo_long];
  305. Function lo(i : Int64) : DWord; [INTERNPROC: fpc_in_lo_qword];
  306. Function lo(q : QWord) : DWord; [INTERNPROC: fpc_in_lo_qword];
  307. Function hi(i : Integer) : byte; [INTERNPROC: fpc_in_hi_Word];
  308. Function hi(w : Word) : byte; [INTERNPROC: fpc_in_hi_Word];
  309. Function hi(l : Longint) : Word; [INTERNPROC: fpc_in_hi_long];
  310. Function hi(l : DWord) : Word; [INTERNPROC: fpc_in_hi_long];
  311. Function hi(i : Int64) : DWord; [INTERNPROC: fpc_in_hi_qword];
  312. Function hi(q : QWord) : DWord; [INTERNPROC: fpc_in_hi_qword];
  313. Function swap (X : Word) : Word;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_word];
  314. Function Swap (X : Integer) : Integer;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_word];
  315. Function swap (X : Longint) : Longint;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_long];
  316. Function Swap (X : Cardinal) : Cardinal;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_long];
  317. Function Swap (X : QWord) : QWord;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_qword];
  318. Function swap (X : Int64) : Int64;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_qword];
  319. Function Align (Addr : PtrInt; Alignment : PtrInt) : PtrInt;{$ifdef SYSTEMINLINE}inline;{$endif}
  320. Function Align (Addr : Pointer; Alignment : PtrInt) : Pointer;{$ifdef SYSTEMINLINE}inline;{$endif}
  321. Function Random(l:longint):longint;
  322. Function Random(l:int64):int64;
  323. Function Random: extended;
  324. Procedure Randomize;
  325. Function abs(l:Longint):Longint;[internconst:fpc_in_const_abs];{$ifdef SYSTEMINLINE}inline;{$endif}
  326. Function abs(l:Int64):Int64;[internconst:fpc_in_const_abs];{$ifdef SYSTEMINLINE}inline;{$endif}
  327. Function sqr(l:Longint):Longint;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}
  328. Function sqr(l:Int64):Int64;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}
  329. Function sqr(l:QWord):QWord;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}
  330. Function odd(l:Longint):Boolean;[internconst:fpc_in_const_odd];{$ifdef SYSTEMINLINE}inline;{$endif}
  331. Function odd(l:Longword):Boolean;[internconst:fpc_in_const_odd];{$ifdef SYSTEMINLINE}inline;{$endif}
  332. Function odd(l:Int64):Boolean;[internconst:fpc_in_const_odd];{$ifdef SYSTEMINLINE}inline;{$endif}
  333. Function odd(l:QWord):Boolean;[internconst:fpc_in_const_odd];{$ifdef SYSTEMINLINE}inline;{$endif}
  334. { float math routines }
  335. {$I mathh.inc}
  336. {****************************************************************************
  337. Addr/Pointer Handling
  338. ****************************************************************************}
  339. Function ptr(sel,off:Longint):farpointer;[internconst:fpc_in_const_ptr];{$ifdef SYSTEMINLINE}inline;{$endif}
  340. Function Cseg:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
  341. Function Dseg:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
  342. Function Sseg:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
  343. {****************************************************************************
  344. PChar and String Handling
  345. ****************************************************************************}
  346. function strpas(p:pchar):shortstring;external name 'FPC_PCHAR_TO_SHORTSTR';
  347. function strlen(p:pchar):longint;external name 'FPC_PCHAR_LENGTH';
  348. { Shortstring functions }
  349. Procedure Delete(Var s:shortstring;index:SizeInt;count:SizeInt);
  350. Procedure Insert(const source:shortstring;Var s:shortstring;index:SizeInt);
  351. Procedure Insert(source:Char;Var s:shortstring;index:SizeInt);
  352. Function Pos(const substr:shortstring;const s:shortstring):SizeInt;
  353. Function Pos(C:Char;const s:shortstring):SizeInt;
  354. Procedure SetString (Var S : Shortstring; Buf : PChar; Len : SizeInt);
  355. Procedure SetString (Var S : AnsiString; Buf : PChar; Len : SizeInt);
  356. Function upCase(const s:shortstring):shortstring;
  357. Function lowerCase(const s:shortstring):shortstring; overload;
  358. Function Space(b:byte):shortstring;
  359. Function hexStr(Val:Longint;cnt:byte):shortstring;
  360. Function OctStr(Val:Longint;cnt:byte):shortstring;
  361. Function binStr(Val:Longint;cnt:byte):shortstring;
  362. Function hexStr(Val:int64;cnt:byte):shortstring;
  363. Function OctStr(Val:int64;cnt:byte):shortstring;
  364. Function binStr(Val:int64;cnt:byte):shortstring;
  365. Function hexStr(Val:Pointer):shortstring;
  366. { Char functions }
  367. Function chr(b : byte) : Char; [INTERNPROC: fpc_in_chr_byte];
  368. Function upCase(c:Char):Char;
  369. Function lowerCase(c:Char):Char; overload;
  370. function pos(const substr : shortstring;c:char): SizeInt;
  371. {****************************************************************************
  372. AnsiString Handling
  373. ****************************************************************************}
  374. Procedure UniqueString(Var S : AnsiString);external name 'FPC_ANSISTR_UNIQUE';
  375. Function Pos (Const Substr : AnsiString; Const Source : AnsiString) : SizeInt;
  376. Function Pos (c : Char; Const s : AnsiString) : SizeInt;
  377. Procedure Insert (Const Source : AnsiString; Var S : AnsiString; Index : SizeInt);
  378. Procedure Delete (Var S : AnsiString; Index,Size: SizeInt);
  379. Function StringOfChar(c : char;l : SizeInt) : AnsiString;
  380. function upcase(const s : ansistring) : ansistring;
  381. function lowercase(const s : ansistring) : ansistring;
  382. {****************************************************************************
  383. WideString Handling
  384. ****************************************************************************}
  385. {$i wstringh.inc}
  386. {****************************************************************************
  387. Untyped File Management
  388. ****************************************************************************}
  389. Procedure Assign(Var f:File;const Name:string);
  390. Procedure Assign(Var f:File;p:pchar);
  391. Procedure Assign(Var f:File;c:char);
  392. Procedure Rewrite(Var f:File;l:Longint);
  393. Procedure Rewrite(Var f:File);
  394. Procedure Reset(Var f:File;l:Longint);
  395. Procedure Reset(Var f:File);
  396. Procedure Close(Var f:File);
  397. Procedure BlockWrite(Var f:File;Const Buf;Count:Longint;Var Result:Longint);
  398. Procedure BlockWrite(Var f:File;Const Buf;Count:Cardinal;var Result:Cardinal);
  399. Procedure BlockWrite(Var f:File;Const Buf;Count:Word;Var Result:Word);
  400. Procedure BlockWrite(Var f:File;Const Buf;Count:Word;Var Result:Integer);
  401. Procedure BlockWrite(Var f:File;Const Buf;Count:Longint);
  402. Procedure BlockRead(Var f:File;Var Buf;count:Longint;Var Result:Longint);
  403. Procedure BlockRead(Var f:File;Var Buf;count:Cardinal;Var Result:Cardinal);
  404. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Word);
  405. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Integer);
  406. Procedure BlockRead(Var f:File;Var Buf;count:Longint);
  407. Function FilePos(Var f:File):Longint;
  408. Function FileSize(Var f:File):Longint;
  409. Procedure Seek(Var f:File;Pos:Longint);
  410. Function EOF(Var f:File):Boolean;
  411. Procedure Erase(Var f:File);
  412. Procedure Rename(Var f:File;const s:string);
  413. Procedure Rename(Var f:File;p:pchar);
  414. Procedure Rename(Var f:File;c:char);
  415. Procedure Truncate (Var F:File);
  416. {****************************************************************************
  417. Typed File Management
  418. ****************************************************************************}
  419. Procedure Assign(Var f:TypedFile;const Name:string);
  420. Procedure Assign(Var f:TypedFile;p:pchar);
  421. Procedure Assign(Var f:TypedFile;c:char);
  422. Procedure Reset(var f : TypedFile); [INTERNPROC: fpc_in_Reset_TypedFile];
  423. Procedure Rewrite(var f : TypedFile); [INTERNPROC: fpc_in_Rewrite_TypedFile];
  424. {****************************************************************************
  425. Text File Management
  426. ****************************************************************************}
  427. Procedure Assign(Var t:Text;const s:string);
  428. Procedure Assign(Var t:Text;p:pchar);
  429. Procedure Assign(Var t:Text;c:char);
  430. Procedure Close(Var t:Text);
  431. Procedure Rewrite(Var t:Text);
  432. Procedure Reset(Var t:Text);
  433. Procedure Append(Var t:Text);
  434. Procedure Flush(Var t:Text);
  435. Procedure Erase(Var t:Text);
  436. Procedure Rename(Var t:Text;const s:string);
  437. Procedure Rename(Var t:Text;p:pchar);
  438. Procedure Rename(Var t:Text;c:char);
  439. Function EOF(Var t:Text):Boolean;
  440. Function EOF:Boolean;
  441. Function EOLn(Var t:Text):Boolean;
  442. Function EOLn:Boolean;
  443. Function SeekEOLn (Var t:Text):Boolean;
  444. Function SeekEOF (Var t:Text):Boolean;
  445. Function SeekEOLn:Boolean;
  446. Function SeekEOF:Boolean;
  447. Procedure SetTextBuf(Var f:Text; Var Buf);[INTERNPROC:fpc_in_settextbuf_file_x];
  448. Procedure SetTextBuf(Var f:Text; Var Buf; Size:Longint);
  449. Procedure SetTextLineEnding(Var f:Text; Ending:string);
  450. {****************************************************************************
  451. Directory Management
  452. ****************************************************************************}
  453. Procedure chdir(const s:string);
  454. Procedure mkdir(const s:string);
  455. Procedure rmdir(const s:string);
  456. Procedure getdir(drivenr:byte;Var dir:shortstring);
  457. Procedure getdir(drivenr:byte;Var dir:ansistring);
  458. {*****************************************************************************
  459. Miscellaneous
  460. *****************************************************************************}
  461. { os independent calls to allow backtraces }
  462. function get_frame:pointer;{$ifdef SYSTEMINLINE}inline;{$endif}
  463. function get_caller_addr(framebp:pointer):pointer;{$ifdef SYSTEMINLINE}inline;{$endif}
  464. function get_caller_frame(framebp:pointer):pointer;{$ifdef SYSTEMINLINE}inline;{$endif}
  465. Function IOResult:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
  466. Function Sptr:Pointer;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_ptr];
  467. Function GetProcessID:SizeUInt;
  468. Function GetThreadID:TThreadID;
  469. {*****************************************************************************
  470. Init / Exit / ExitProc
  471. *****************************************************************************}
  472. Function Paramcount:Longint;
  473. Function ParamStr(l:Longint):string;
  474. Procedure Dump_Stack(var f : text;bp:pointer);
  475. Procedure RunError(w:Word);
  476. Procedure RunError;{$ifdef SYSTEMINLINE}inline;{$endif}
  477. Procedure halt(errnum:byte);
  478. Procedure AddExitProc(Proc:TProcedure);
  479. Procedure halt;{$ifdef SYSTEMINLINE}inline;{$endif}
  480. { Need to be exported for threads unit }
  481. Procedure SysInitExceptions;
  482. procedure SysInitStdIO;
  483. Procedure SysResetFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
  484. {*****************************************************************************
  485. Abstract/Assert/Error Handling
  486. *****************************************************************************}
  487. function ArrayStringToPPchar(const S:Array of AnsiString;reserveentries:Longint):ppchar; // const ?
  488. Function StringToPPChar(Var S:AnsiString;ReserveEntries:integer):ppchar;
  489. Function StringToPPChar(S: PChar;ReserveEntries:integer):ppchar;
  490. procedure AbstractError;external name 'FPC_ABSTRACTERROR';
  491. Function SysBackTraceStr(Addr:Pointer): ShortString;
  492. Procedure SysAssert(Const Msg,FName:ShortString;LineNo:Longint;ErrorAddr:Pointer);
  493. { Error handlers }
  494. Type
  495. TBackTraceStrFunc = Function (Addr: Pointer): ShortString;
  496. TErrorProc = Procedure (ErrNo : Longint; Address,Frame : Pointer);
  497. TAbstractErrorProc = Procedure;
  498. TAssertErrorProc = Procedure(const msg,fname:ShortString;lineno:longint;erroraddr:pointer);
  499. const
  500. BackTraceStrFunc : TBackTraceStrFunc = @SysBackTraceStr;
  501. ErrorProc : TErrorProc = nil;
  502. AbstractErrorProc : TAbstractErrorProc = nil;
  503. AssertErrorProc : TAssertErrorProc = @SysAssert;
  504. {*****************************************************************************
  505. SetJmp/LongJmp
  506. *****************************************************************************}
  507. {$i setjumph.inc}
  508. {*****************************************************************************
  509. Object Pascal support
  510. *****************************************************************************}
  511. {$i objpash.inc}
  512. {*****************************************************************************
  513. Variant support
  514. *****************************************************************************}
  515. {$i varianth.inc}
  516. {*****************************************************************************
  517. Internal helper routines support
  518. *****************************************************************************}
  519. {$i dynarrh.inc}
  520. {$i compproc.inc}
  521. {*****************************************************************************
  522. Heap
  523. *****************************************************************************}
  524. {$i heaph.inc}
  525. {*****************************************************************************
  526. Thread support
  527. *****************************************************************************}
  528. { Generic threadmanager }
  529. {$i threadh.inc}
  530. {*****************************************************************************
  531. FPDoc phony declarations.
  532. *****************************************************************************}
  533. {$ifdef fpdocsystem}
  534. {$i system.fpd}
  535. {$endif}