systemh.inc 16 KB

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