systemh.inc 26 KB

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