systemh.inc 15 KB

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