systemh.inc 24 KB

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