systemh.inc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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 : Word;
  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 Assign(Var f:File;p:pchar);
  206. Procedure Assign(Var f:File;c:char);
  207. Procedure Rewrite(Var f:File;l:Word);
  208. Procedure Rewrite(Var f:File);
  209. Procedure Reset(Var f:File;l:Word);
  210. Procedure Reset(Var f:File);
  211. Procedure Close(Var f:File);
  212. Procedure BlockWrite(Var f:File;Var Buf;Count:Longint;Var Result:Longint);
  213. Procedure BlockWrite(Var f:File;Var Buf;Count:Word;Var Result:Word);
  214. Procedure BlockWrite(Var f:File;Var Buf;Count:Word;Var Result:Integer);
  215. Procedure BlockWrite(Var f:File;Var Buf;Count:Longint);
  216. Procedure BlockRead(Var f:File;Var Buf;count:Longint;Var Result:Longint);
  217. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Word);
  218. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Integer);
  219. Procedure BlockRead(Var f:File;Var Buf;count:Longint);
  220. Function FilePos(Var f:File):Longint;
  221. Function FileSize(Var f:File):Longint;
  222. Procedure Seek(Var f:File;Pos:Longint);
  223. Function EOF(Var f:File):Boolean;
  224. Procedure Erase(Var f:File);
  225. Procedure Rename(Var f:File;const s:string);
  226. Procedure Rename(Var f:File;p:pchar);
  227. Procedure Rename(Var f:File;c:char);
  228. Procedure Truncate (Var F:File);
  229. {****************************************************************************
  230. Typed File Management
  231. ****************************************************************************}
  232. Procedure Assign(Var f:TypedFile;const Name:string);
  233. Procedure Assign(Var f:TypedFile;p:pchar);
  234. Procedure Assign(Var f:TypedFile;c:char);
  235. Procedure Rewrite(Var f:TypedFile);
  236. Procedure Reset(Var f:TypedFile);
  237. {****************************************************************************
  238. Text File Management
  239. ****************************************************************************}
  240. Procedure Assign(Var t:Text;const s:string);
  241. Procedure Assign(Var t:Text;p:pchar);
  242. Procedure Assign(Var t:Text;c:char);
  243. Procedure Close(Var t:Text);
  244. Procedure Rewrite(Var t:Text);
  245. Procedure Reset(Var t:Text);
  246. Procedure Append(Var t:Text);
  247. Procedure Flush(Var t:Text);
  248. Procedure Erase(Var t:Text);
  249. Procedure Rename(Var t:Text;const s:string);
  250. Procedure Rename(Var t:Text;p:pchar);
  251. Procedure Rename(Var t:Text;c:char);
  252. Function EOF(Var t:Text):Boolean;
  253. Function EOF:Boolean;
  254. Function EOLn(Var t:Text):Boolean;
  255. Function EOLn:Boolean;
  256. Function SeekEOLn (Var F:Text):Boolean;
  257. Function SeekEOF (Var F:Text):Boolean;
  258. Function SeekEOLn:Boolean;
  259. Function SeekEOF:Boolean;
  260. Procedure SetTextBuf(Var f:Text; Var Buf);
  261. Procedure SetTextBuf(Var f:Text; Var Buf; Size:Word);
  262. {****************************************************************************
  263. Directory Management
  264. ****************************************************************************}
  265. Procedure chdir(const s:string);
  266. Procedure mkdir(const s:string);
  267. Procedure rmdir(const s:string);
  268. Procedure getdir(drivenr:byte;Var dir:string);
  269. {*****************************************************************************
  270. Miscelleaous
  271. *****************************************************************************}
  272. Function IOResult:Word;
  273. Function Sptr:Longint;
  274. {*****************************************************************************
  275. Init / Exit / ExitProc
  276. *****************************************************************************}
  277. Function Paramcount:Longint;
  278. Function ParamStr(l:Longint):string;
  279. Procedure Dump_Stack(bp:Longint);
  280. Procedure RunError(w:Word);
  281. Procedure RunError;
  282. Procedure halt(errnum:byte);
  283. Procedure halt;
  284. Procedure AddExitProc(Proc:TProcedure);
  285. {
  286. $Log$
  287. Revision 1.7 1998-05-22 12:34:11 peter
  288. * fixed the optimizes of daniel
  289. Revision 1.6 1998/05/21 19:31:00 peter
  290. * objects compiles for linux
  291. + assign(pchar), assign(char), rename(pchar), rename(char)
  292. * fixed read_text_as_array
  293. + read_text_as_pchar which was not yet in the rtl
  294. Revision 1.5 1998/05/12 10:42:45 peter
  295. * moved getopts to inc/, all supported OS's need argc,argv exported
  296. + strpas, strlen are now exported in the systemunit
  297. * removed logs
  298. * removed $ifdef ver_above
  299. Revision 1.4 1998/04/16 12:30:47 peter
  300. + inc(pchar), dec(pchar), incc(pchar,a),dec(pchar,a)
  301. }