systemh.inc 17 KB

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