systemh.inc 17 KB

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