systemh.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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. {$ENDIF}
  31. { some type aliases }
  32. dword = cardinal;
  33. longword = cardinal;
  34. { Zero - terminated strings }
  35. PChar = ^Char;
  36. PPChar = ^PChar;
  37. { procedure type }
  38. TProcedure = Procedure;
  39. const
  40. { max. values for longint and int}
  41. maxLongint = $7fffffff;
  42. maxint = 32767;
  43. { Compatibility With TP }
  44. {$ifdef i386}
  45. Test8086 : byte = 2; { Always i386 or newer }
  46. Test8087 : byte = 3; { Always 387 or newer. Emulated if needed. }
  47. {$endif i386}
  48. {$ifdef m68k}
  49. Test68000 : byte = 0; { Must be determined at startup for both }
  50. Test68881 : byte = 0;
  51. {$endif}
  52. { max level in dumping on error }
  53. Max_Frame_Dump : Word = 20;
  54. { Exit Procedure handling consts and types }
  55. ExitProc : pointer=nil;
  56. Erroraddr: pointer = nil;
  57. Errorcode: Word = 0;
  58. { file input modes }
  59. fmClosed = $D7B0;
  60. fmInput = $D7B1;
  61. fmOutput = $D7B2;
  62. fmInOut = $D7B3;
  63. fmAppend = $D7B4;
  64. Filemode : byte = 2;
  65. var
  66. { Standard In- and Output }
  67. Output,
  68. Input,
  69. StdErr : Text;
  70. ExitCode,
  71. InOutRes : Longint;
  72. StackBottom,
  73. LowestStack,
  74. RandSeed : Longint;
  75. {****************************************************************************
  76. Processor specific routines
  77. ****************************************************************************}
  78. Procedure Move(Var source,dest;count:Longint);
  79. Procedure FillChar(Var x;count:Longint;Value:Char);
  80. Procedure FillChar(Var x;count:Longint;Value:byte);
  81. Procedure FillWord(Var x;count:Longint;Value:Word);
  82. {****************************************************************************
  83. Math Routines
  84. ****************************************************************************}
  85. Function lo(w:Word):byte;
  86. Function lo(l:Longint):Word;
  87. Function lo(i:Integer):byte;
  88. Function lo(B: Byte):Byte;
  89. Function hi(w:Word):byte;
  90. Function hi(i:Integer):byte;
  91. Function hi(l:Longint):Word;
  92. Function Hi(B : Byte): byte;
  93. Procedure Inc(Var i:cardinal);
  94. Procedure Inc(Var i:Longint);
  95. Procedure Inc(Var i:Integer);
  96. Procedure Inc(Var i:Word);
  97. Procedure Inc(Var i:shortint);
  98. Procedure Inc(Var i:byte);
  99. Procedure Inc(Var c:Char);
  100. Procedure Inc(Var p:PChar);
  101. Procedure Dec(Var i:cardinal);
  102. Procedure Dec(Var i:Longint);
  103. Procedure Dec(Var i:Integer);
  104. Procedure Dec(Var i:Word);
  105. Procedure Dec(Var i:shortint);
  106. Procedure Dec(Var i:byte);
  107. Procedure Dec(Var c:Char);
  108. Procedure Dec(Var p:PChar);
  109. Function Chr(b:byte):Char;
  110. Function Length(s:string):byte;
  111. Procedure Dec(Var i:cardinal;a:Longint);
  112. Procedure Inc(Var i:cardinal;a:Longint);
  113. Procedure Dec(Var i:Longint;a:Longint);
  114. Procedure Inc(Var i:Longint;a:Longint);
  115. Procedure Dec(Var i:Word;a:Longint);
  116. Procedure Inc(Var i:Word;a:Longint);
  117. Procedure Dec(Var i:Integer;a:Longint);
  118. Procedure Inc(Var i:Integer;a:Longint);
  119. Procedure Dec(Var i:byte;a:Longint);
  120. Procedure Inc(Var i:byte;a:Longint);
  121. Procedure Dec(Var i:shortint;a:Longint);
  122. Procedure Inc(Var i:shortint;a:Longint);
  123. Procedure Dec(Var c:Char;a:Longint);
  124. Procedure Inc(Var c:Char;a:Longint);
  125. Procedure Dec(Var p:PChar;a:Longint);
  126. Procedure Inc(Var p:PChar;a:Longint);
  127. Function Swap (X:Word):Word;
  128. Function Swap (X:Integer):Integer;
  129. Function Swap (X:Cardinal):Cardinal;
  130. Function Swap (X:Longint):Longint;
  131. Function Random(l:Longint):Longint;
  132. Function Random:real;
  133. Procedure Randomize;
  134. Function abs(l:Longint):Longint;
  135. Function sqr(l:Longint):Longint;
  136. Function odd(l:Longint):Boolean;
  137. { float mathe routines }
  138. {$I mathh.inc}
  139. {****************************************************************************
  140. Memory management
  141. ****************************************************************************}
  142. Procedure getmem(Var p:pointer;Size:Longint);
  143. Procedure freemem(Var p:pointer;Size:Longint);
  144. Function memavail:Longint;
  145. Function maxavail:Longint;
  146. Function ptr(sel,off:Longint):pointer;
  147. Function Addr (Var X):pointer;
  148. Function Cseg:Word;
  149. Function Dseg:Word;
  150. Function Sseg:Word;
  151. {****************************************************************************
  152. PChar Handling
  153. ****************************************************************************}
  154. function strpas(p:pchar):string;
  155. function strlen(p:pchar):longint;
  156. {****************************************************************************
  157. String Handling
  158. ****************************************************************************}
  159. Function copy(const s:string;index:Integer;count:Integer):string;
  160. Procedure Delete(Var s:string;index:Integer;count:Integer);
  161. Procedure Insert(const source:string;Var s:string;index:Integer);
  162. Function Pos(const substr:string;const s:string):byte;
  163. Function Pos(C:Char;const s:string):byte;
  164. Function upCase(c:Char):Char;
  165. Function upCase(const s:string):string;
  166. Function lowerCase(c:Char):Char;
  167. Function lowerCase(const s:string):string;
  168. Function Space(b:byte):string;
  169. Function hexStr(Val:Longint;cnt:byte):string;
  170. Function binStr(Val:Longint;cnt:byte):string;
  171. Procedure Val(const s:string;Var l:Longint;Var code:Word);
  172. Procedure Val(const s:string;Var l:Longint;Var code:Integer);
  173. Procedure Val(const s:string;Var l:Longint);
  174. Procedure Val(const s:string;Var b:byte;Var code:Word);
  175. Procedure Val(const s:string;Var b:byte;Var code:Integer);
  176. Procedure Val(const s:string;Var b:byte);
  177. Procedure Val(const s:string;Var b:shortint;Var code:Word);
  178. Procedure Val(const s:string;Var b:shortint;Var code:Integer);
  179. Procedure Val(const s:string;Var b:shortint);
  180. Procedure Val(const s:string;Var b:Word;Var code:Word);
  181. Procedure Val(const s:string;Var b:Word;Var code:Integer);
  182. Procedure Val(const s:string;Var b:Word);
  183. Procedure Val(const s:string;Var b:Integer;Var code:Word);
  184. Procedure Val(const s:string;Var b:Integer;Var code:Integer);
  185. Procedure Val(const s:string;Var b:Integer);
  186. Procedure Val(const s:string;Var d:Real;Var code:Word);
  187. Procedure Val(const s:string;Var d:Real;Var code:Integer);
  188. Procedure Val(const s:string;Var d:Real);
  189. Procedure Val(const s:string;Var d:single;Var code:Word);
  190. Procedure Val(const s:string;Var d:single;Var code:Integer);
  191. Procedure Val(const s:string;Var d:single);
  192. Procedure Val(const s:string;Var d:Extended;Var code:Word);
  193. Procedure Val(const s:string;Var d:Extended;Var code:Integer);
  194. Procedure Val(const s:string;Var d:Extended);
  195. Procedure Val(const s:string;Var d:comp;Var code:Word);
  196. Procedure Val(const s:string;Var d:comp;Var code:Integer);
  197. Procedure Val(const s:string;Var d:comp);
  198. Procedure Val(const s:string;Var v:cardinal;Var code:Word);
  199. Procedure Val(const s:string;Var v:cardinal;Var code:Integer);
  200. Procedure Val(const s:string;Var v:cardinal);
  201. {****************************************************************************
  202. Untyped File Management
  203. ****************************************************************************}
  204. Procedure Assign(Var f:File;const Name:string);
  205. Procedure Rewrite(Var f:File;l:Word);
  206. Procedure Rewrite(Var f:File);
  207. Procedure Reset(Var f:File;l:Word);
  208. Procedure Reset(Var f:File);
  209. Procedure Close(Var f:File);
  210. Procedure BlockWrite(Var f:File;Var Buf;Count:Longint;Var Result:Longint);
  211. Procedure BlockWrite(Var f:File;Var Buf;Count:Word;Var Result:Word);
  212. Procedure BlockWrite(Var f:File;Var Buf;Count:Word;Var Result:Integer);
  213. Procedure BlockWrite(Var f:File;Var Buf;Count:Longint);
  214. Procedure BlockRead(Var f:File;Var Buf;count:Longint;Var Result:Longint);
  215. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Word);
  216. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Integer);
  217. Procedure BlockRead(Var f:File;Var Buf;count:Longint);
  218. Function FilePos(Var f:File):Longint;
  219. Function FileSize(Var f:File):Longint;
  220. Procedure Seek(Var f:File;Pos:Longint);
  221. Function EOF(Var f:File):Boolean;
  222. Procedure Erase(Var f:File);
  223. Procedure Rename(Var f:File;const s:string);
  224. Procedure Truncate (Var F:File);
  225. {****************************************************************************
  226. Typed File Management
  227. ****************************************************************************}
  228. Procedure Assign(Var f:TypedFile;const Name:string);
  229. Procedure Rewrite(Var f:TypedFile);
  230. Procedure Reset(Var f:TypedFile);
  231. {****************************************************************************
  232. Text File Management
  233. ****************************************************************************}
  234. Procedure Assign(Var t:Text;const s:string);
  235. Procedure Close(Var t:Text);
  236. Procedure Rewrite(Var t:Text);
  237. Procedure Reset(Var t:Text);
  238. Procedure Append(Var t:Text);
  239. Procedure Flush(Var t:Text);
  240. Procedure Erase(Var t:Text);
  241. Procedure Rename(Var t:Text;const s:string);
  242. Function EOF(Var t:Text):Boolean;
  243. Function EOF:Boolean;
  244. Function EOLn(Var t:Text):Boolean;
  245. Function EOLn:Boolean;
  246. Function SeekEOLn (Var F:Text):Boolean;
  247. Function SeekEOF (Var F:Text):Boolean;
  248. Function SeekEOLn:Boolean;
  249. Function SeekEOF:Boolean;
  250. Procedure SetTextBuf(Var f:Text; Var Buf);
  251. Procedure SetTextBuf(Var f:Text; Var Buf; Size:Word);
  252. {****************************************************************************
  253. Directory Management
  254. ****************************************************************************}
  255. Procedure chdir(const s:string);
  256. Procedure mkdir(const s:string);
  257. Procedure rmdir(const s:string);
  258. Procedure getdir(drivenr:byte;Var dir:string);
  259. {*****************************************************************************
  260. Miscelleaous
  261. *****************************************************************************}
  262. Function IOResult:Word;
  263. Function Sptr:Longint;
  264. {*****************************************************************************
  265. Init / Exit / ExitProc
  266. *****************************************************************************}
  267. Function Paramcount:Longint;
  268. Function ParamStr(l:Longint):string;
  269. Procedure Dump_Stack(bp:Longint);
  270. Procedure RunError(w:Word);
  271. Procedure RunError;
  272. Procedure halt(errnum:byte);
  273. Procedure halt;
  274. Procedure AddExitProc(Proc:TProcedure);
  275. {
  276. $Log$
  277. Revision 1.5 1998-05-12 10:42:45 peter
  278. * moved getopts to inc/, all supported OS's need argc,argv exported
  279. + strpas, strlen are now exported in the systemunit
  280. * removed logs
  281. * removed $ifdef ver_above
  282. Revision 1.4 1998/04/16 12:30:47 peter
  283. + inc(pchar), dec(pchar), incc(pchar,a),dec(pchar,a)
  284. }