systemh.inc 27 KB

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