systemh.inc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Run time library.
  4. Copyright (c) 1993,97 by the Free Pascal development team
  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. This File contains the OS independent declarations of the system unit
  13. *****************************************************************************}
  14. {****************************************************************************
  15. Support for multiple compiler versions
  16. ****************************************************************************}
  17. {$i version.inc}
  18. {****************************************************************************
  19. Global Types and Constants
  20. ****************************************************************************}
  21. Type
  22. Longint = $80000000..$7fffffff;
  23. Integer = -32768..32767;
  24. shortint = -128..127;
  25. byte = 0..255;
  26. Word = 0..65535;
  27. { at least declare Turbo Pascal real types }
  28. {$ifdef i386}
  29. Double = real;
  30. {$define SUPPORT_EXTENDED}
  31. {$define SUPPORT_COMP}
  32. {$endif}
  33. { some type aliases }
  34. dword = cardinal;
  35. longword = cardinal;
  36. { Zero - terminated strings }
  37. PChar = ^Char;
  38. PPChar = ^PChar;
  39. { procedure type }
  40. TProcedure = Procedure;
  41. const
  42. { max. values for longint and int}
  43. maxLongint = $7fffffff;
  44. maxint = 32767;
  45. { Compatibility With TP }
  46. {$ifdef i386}
  47. Test8086 : byte = 2; { Always i386 or newer }
  48. Test8087 : byte = 3; { Always 387 or newer. Emulated if needed. }
  49. {$endif i386}
  50. {$ifdef m68k}
  51. Test68000 : byte = 0; { Must be determined at startup for both }
  52. Test68881 : byte = 0;
  53. {$endif}
  54. { max level in dumping on error }
  55. Max_Frame_Dump : Word = 20;
  56. { Exit Procedure handling consts and types }
  57. ExitProc : pointer=nil;
  58. Erroraddr: pointer = nil;
  59. Errorcode: Word = 0;
  60. { file input modes }
  61. fmClosed = $D7B0;
  62. fmInput = $D7B1;
  63. fmOutput = $D7B2;
  64. fmInOut = $D7B3;
  65. fmAppend = $D7B4;
  66. Filemode : byte = 2;
  67. var
  68. { Standard In- and Output }
  69. Output,
  70. Input,
  71. StdErr : Text;
  72. ExitCode,
  73. InOutRes : Word;
  74. StackBottom,
  75. LowestStack,
  76. RandSeed : Longint;
  77. {****************************************************************************
  78. Processor specific routines
  79. ****************************************************************************}
  80. Procedure Move(Var source,dest;count:Longint);
  81. Procedure FillChar(Var x;count:Longint;Value:Char);
  82. Procedure FillChar(Var x;count:Longint;Value:byte);
  83. {$ifndef RTLLITE}
  84. Procedure FillWord(Var x;count:Longint;Value:Word);
  85. {$endif RTLLITE}
  86. {****************************************************************************
  87. Math Routines
  88. ****************************************************************************}
  89. {$ifndef RTLLITE}
  90. Function lo(w:Word):byte;
  91. Function lo(l:Longint):Word;
  92. Function lo(i:Integer):byte;
  93. Function lo(B: Byte):Byte;
  94. Function hi(w:Word):byte;
  95. Function hi(i:Integer):byte;
  96. Function hi(l:Longint):Word;
  97. Function Hi(B : Byte): byte;
  98. {$endif RTLLITE}
  99. Procedure Inc(Var i:cardinal);
  100. Procedure Inc(Var i:Longint);
  101. Procedure Inc(Var i:Integer);
  102. Procedure Inc(Var i:Word);
  103. Procedure Inc(Var i:shortint);
  104. Procedure Inc(Var i:byte);
  105. Procedure Inc(Var c:Char);
  106. Procedure Inc(Var p:PChar);
  107. Procedure Dec(Var i:cardinal);
  108. Procedure Dec(Var i:Longint);
  109. Procedure Dec(Var i:Integer);
  110. Procedure Dec(Var i:Word);
  111. Procedure Dec(Var i:shortint);
  112. Procedure Dec(Var i:byte);
  113. Procedure Dec(Var c:Char);
  114. Procedure Dec(Var p:PChar);
  115. Function Chr(b:byte):Char;
  116. Function Length(s:string):byte;
  117. {$ifndef RTLLITE}
  118. Procedure Dec(Var i:cardinal;a:Longint);
  119. Procedure Inc(Var i:cardinal;a:Longint);
  120. Procedure Dec(Var i:Longint;a:Longint);
  121. Procedure Inc(Var i:Longint;a:Longint);
  122. Procedure Dec(Var i:Word;a:Longint);
  123. Procedure Inc(Var i:Word;a:Longint);
  124. Procedure Dec(Var i:Integer;a:Longint);
  125. Procedure Inc(Var i:Integer;a:Longint);
  126. Procedure Dec(Var i:byte;a:Longint);
  127. Procedure Inc(Var i:byte;a:Longint);
  128. Procedure Dec(Var i:shortint;a:Longint);
  129. Procedure Inc(Var i:shortint;a:Longint);
  130. Procedure Dec(Var c:Char;a:Longint);
  131. Procedure Inc(Var c:Char;a:Longint);
  132. Procedure Dec(Var p:PChar;a:Longint);
  133. Procedure Inc(Var p:PChar;a:Longint);
  134. Function Swap (X:Word):Word;
  135. Function Swap (X:Integer):Integer;
  136. Function Swap (X:Cardinal):Cardinal;
  137. Function Swap (X:Longint):Longint;
  138. {$endif RTLLITE}
  139. Function Random(l:Longint):Longint;
  140. Function Random:real;
  141. Procedure Randomize;
  142. Function abs(l:Longint):Longint;
  143. Function sqr(l:Longint):Longint;
  144. Function odd(l:Longint):Boolean;
  145. { float mathe routines }
  146. {$I mathh.inc}
  147. {****************************************************************************
  148. Memory management
  149. ****************************************************************************}
  150. Procedure getmem(Var p:pointer;Size:Longint);
  151. Procedure freemem(Var p:pointer;Size:Longint);
  152. Function memavail:Longint;
  153. Function maxavail:Longint;
  154. {$ifndef RTLLITE}
  155. Function ptr(sel,off:Longint):pointer;
  156. Function Addr (Var X):pointer;
  157. Function Cseg:Word;
  158. Function Dseg:Word;
  159. Function Sseg:Word;
  160. {$endif RTLLITE}
  161. {****************************************************************************
  162. PChar Handling
  163. ****************************************************************************}
  164. function strpas(p:pchar):string;
  165. function strlen(p:pchar):longint;
  166. Function copy(const s:string;index:Integer;count:Integer):string;
  167. Procedure Delete(Var s:string;index:Integer;count:Integer);
  168. Procedure Insert(const source:string;Var s:string;index:Integer);
  169. Function Pos(const substr:string;const s:string):byte;
  170. Function Pos(C:Char;const s:string):byte;
  171. Function upCase(c:Char):Char;
  172. Function upCase(const s:string):string;
  173. Function lowerCase(c:Char):Char;
  174. Function lowerCase(const s:string):string;
  175. Function Space(b:byte):string;
  176. Function hexStr(Val:Longint;cnt:byte):string;
  177. Function binStr(Val:Longint;cnt:byte):string;
  178. Procedure Val(const s:string;Var l:Longint;Var code:Word);
  179. Procedure Val(const s:string;Var l:Longint;Var code:Integer);
  180. Procedure Val(const s:string;Var l:Longint);
  181. Procedure Val(const s:string;Var b:byte;Var code:Word);
  182. Procedure Val(const s:string;Var b:byte;Var code:Integer);
  183. Procedure Val(const s:string;Var b:byte);
  184. Procedure Val(const s:string;Var b:shortint;Var code:Word);
  185. Procedure Val(const s:string;Var b:shortint;Var code:Integer);
  186. Procedure Val(const s:string;Var b:shortint);
  187. Procedure Val(const s:string;Var b:Word;Var code:Word);
  188. Procedure Val(const s:string;Var b:Word;Var code:Integer);
  189. Procedure Val(const s:string;Var b:Word);
  190. Procedure Val(const s:string;Var b:Integer;Var code:Word);
  191. Procedure Val(const s:string;Var b:Integer;Var code:Integer);
  192. Procedure Val(const s:string;Var b:Integer);
  193. Procedure Val(const s:string;Var d:Real;Var code:Word);
  194. Procedure Val(const s:string;Var d:Real;Var code:Integer);
  195. Procedure Val(const s:string;Var d:Real);
  196. Procedure Val(const s:string;Var d:single;Var code:Word);
  197. Procedure Val(const s:string;Var d:single;Var code:Integer);
  198. Procedure Val(const s:string;Var d:single);
  199. {$ifdef SUPPORT_EXTENDED}
  200. Procedure Val(const s:string;Var d:Extended;Var code:Word);
  201. Procedure Val(const s:string;Var d:Extended;Var code:Integer);
  202. Procedure Val(const s:string;Var d:Extended);
  203. {$endif SUPPORT_EXTENDED}
  204. {$ifdef SUPPORT_COMP}
  205. Procedure Val(const s:string;Var d:comp;Var code:Word);
  206. Procedure Val(const s:string;Var d:comp;Var code:Integer);
  207. Procedure Val(const s:string;Var d:comp);
  208. {$endif SUPPORT_COMP}
  209. Procedure Val(const s:string;Var v:cardinal;Var code:Word);
  210. Procedure Val(const s:string;Var v:cardinal;Var code:Integer);
  211. Procedure Val(const s:string;Var v:cardinal);
  212. {****************************************************************************
  213. AnsiString Handling
  214. ****************************************************************************}
  215. {$ifdef UseAnsiStrings }
  216. Procedure SetLength (Var S : AnsiString; l : Longint);
  217. Procedure UniqueAnsiString (Var S : AnsiString);
  218. Function Length (Const S : AnsiString) : Longint;
  219. Function Copy (Const S : AnsiString; Index,Size : Longint) : AnsiString;
  220. Function Pos (Const Substr : AnsiString; Const Source : AnsiString) : Longint;
  221. Procedure Insert (Const Source : AnsiString; Var S : AnsiString; Index : Longint);
  222. Procedure Delete (Var S : AnsiString; Index,Size: Longint);
  223. Procedure Val (Const S : AnsiString; var R : real; Var Code : Integer);
  224. {
  225. Procedure Val (Const S : AnsiString; var D : Double; Var Code : Integer);
  226. }
  227. Procedure Val (Const S : AnsiString; var E : Extended; Code : Integer);
  228. Procedure Val (Const S : AnsiString; var C : Cardinal; Code : Integer);
  229. Procedure Val (Const S : AnsiString; var L : Longint; Var Code : Integer);
  230. Procedure Val (Const S : AnsiString; var W : Word; Var Code : Integer);
  231. Procedure Val (Const S : AnsiString; var I : Integer; Var Code : Integer);
  232. Procedure Val (Const S : AnsiString; var B : Byte; Var Code : Integer);
  233. Procedure Val (Const S : AnsiString; var SI : ShortInt; Var Code : Integer);
  234. {
  235. Procedure Str (Const R : Real;Len, fr : longint; Var S : AnsiString);
  236. Procedure Str (Const D : Double;Len,fr : longint; Var S : AnsiString);
  237. Procedure Str (Const E : Extended;Len,fr : longint; Var S : AnsiString);
  238. Procedure Str (Const C : Cardinal;len : Longint; Var S : AnsiString);
  239. Procedure Str (Const L : LongInt;len : longint; Var S : AnsiString);
  240. Procedure Str (Const W : Word;len : longint; Var S : AnsiString);
  241. Procedure Str (Const I : Integer;len : Longint; Var S : AnsiString);
  242. Procedure Str (Const B : Byte; Len : longint; Var S : AnsiString);
  243. Procedure Str (Const SI : ShortInt; Len : longint; Var S : AnsiString);
  244. }
  245. {$endif}
  246. {****************************************************************************
  247. Untyped File Management
  248. ****************************************************************************}
  249. Procedure Assign(Var f:File;const Name:string);
  250. Procedure Assign(Var f:File;p:pchar);
  251. Procedure Assign(Var f:File;c:char);
  252. Procedure Rewrite(Var f:File;l:Word);
  253. Procedure Rewrite(Var f:File);
  254. Procedure Reset(Var f:File;l:Word);
  255. Procedure Reset(Var f:File);
  256. Procedure Close(Var f:File);
  257. Procedure BlockWrite(Var f:File;Var Buf;Count:Longint;Var Result:Longint);
  258. Procedure BlockWrite(Var f:File;Var Buf;Count:Word;Var Result:Word);
  259. Procedure BlockWrite(Var f:File;Var Buf;Count:Word;Var Result:Integer);
  260. Procedure BlockWrite(Var f:File;Var Buf;Count:Longint);
  261. Procedure BlockRead(Var f:File;Var Buf;count:Longint;Var Result:Longint);
  262. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Word);
  263. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Integer);
  264. Procedure BlockRead(Var f:File;Var Buf;count:Longint);
  265. Function FilePos(Var f:File):Longint;
  266. Function FileSize(Var f:File):Longint;
  267. Procedure Seek(Var f:File;Pos:Longint);
  268. Function EOF(Var f:File):Boolean;
  269. Procedure Erase(Var f:File);
  270. Procedure Rename(Var f:File;const s:string);
  271. Procedure Rename(Var f:File;p:pchar);
  272. Procedure Rename(Var f:File;c:char);
  273. Procedure Truncate (Var F:File);
  274. {****************************************************************************
  275. Typed File Management
  276. ****************************************************************************}
  277. Procedure Assign(Var f:TypedFile;const Name:string);
  278. Procedure Assign(Var f:TypedFile;p:pchar);
  279. Procedure Assign(Var f:TypedFile;c:char);
  280. Procedure Rewrite(Var f:TypedFile);
  281. Procedure Reset(Var f:TypedFile);
  282. {****************************************************************************
  283. Text File Management
  284. ****************************************************************************}
  285. Procedure Assign(Var t:Text;const s:string);
  286. Procedure Assign(Var t:Text;p:pchar);
  287. Procedure Assign(Var t:Text;c:char);
  288. Procedure Close(Var t:Text);
  289. Procedure Rewrite(Var t:Text);
  290. Procedure Reset(Var t:Text);
  291. Procedure Append(Var t:Text);
  292. Procedure Flush(Var t:Text);
  293. Procedure Erase(Var t:Text);
  294. Procedure Rename(Var t:Text;const s:string);
  295. Procedure Rename(Var t:Text;p:pchar);
  296. Procedure Rename(Var t:Text;c:char);
  297. Function EOF(Var t:Text):Boolean;
  298. Function EOF:Boolean;
  299. Function EOLn(Var t:Text):Boolean;
  300. Function EOLn:Boolean;
  301. Function SeekEOLn (Var F:Text):Boolean;
  302. Function SeekEOF (Var F:Text):Boolean;
  303. Function SeekEOLn:Boolean;
  304. Function SeekEOF:Boolean;
  305. Procedure SetTextBuf(Var f:Text; Var Buf);
  306. Procedure SetTextBuf(Var f:Text; Var Buf; Size:Word);
  307. {****************************************************************************
  308. Directory Management
  309. ****************************************************************************}
  310. Procedure chdir(const s:string);
  311. Procedure mkdir(const s:string);
  312. Procedure rmdir(const s:string);
  313. Procedure getdir(drivenr:byte;Var dir:string);
  314. {*****************************************************************************
  315. Miscelleaous
  316. *****************************************************************************}
  317. Function IOResult:Word;
  318. Function Sptr:Longint;
  319. {*****************************************************************************
  320. Init / Exit / ExitProc
  321. *****************************************************************************}
  322. Function Paramcount:Longint;
  323. Function ParamStr(l:Longint):string;
  324. Procedure Dump_Stack(bp:Longint);
  325. Procedure RunError(w:Word);
  326. Procedure RunError;
  327. Procedure halt(errnum:byte);
  328. Procedure halt;
  329. Procedure AddExitProc(Proc:TProcedure);
  330. {
  331. $Log$
  332. Revision 1.12 1998-06-15 15:16:27 daniel
  333. * RTLLITE conditional added to produce smaller RTL
  334. Revision 1.11 1998/06/08 12:38:23 michael
  335. Implemented rtti, inserted ansistrings again
  336. Revision 1.10 1998/06/04 23:46:02 peter
  337. * comp,extended are only i386 added support_comp,support_extended
  338. Revision 1.9 1998/06/04 08:26:03 pierre
  339. * boolean internal definition again (needed to compile
  340. older RTL's)
  341. Revision 1.8 1998/06/03 23:39:53 peter
  342. + boolean=bytebool
  343. Revision 1.7 1998/05/22 12:34:11 peter
  344. * fixed the optimizes of daniel
  345. Revision 1.6 1998/05/21 19:31:00 peter
  346. * objects compiles for linux
  347. + assign(pchar), assign(char), rename(pchar), rename(char)
  348. * fixed read_text_as_array
  349. + read_text_as_pchar which was not yet in the rtl
  350. Revision 1.5 1998/05/12 10:42:45 peter
  351. * moved getopts to inc/, all supported OS's need argc,argv exported
  352. + strpas, strlen are now exported in the systemunit
  353. * removed logs
  354. * removed $ifdef ver_above
  355. Revision 1.4 1998/04/16 12:30:47 peter
  356. + inc(pchar), dec(pchar), incc(pchar,a),dec(pchar,a)
  357. }