systemh.inc 26 KB

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