systemh.inc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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. {TypedFile is standard from Version 0_9_3}
  19. {$IFDEF VER_ABOVE0_9_3}
  20. {$DEFINE TypedFile}
  21. {$ENDIF VER_ABOVE0_9_3}
  22. {Ord() is Intern from Version 0_9_5}
  23. {$IFDEF VER_ABOVE0_9_5}
  24. {$DEFINE OrdIntern}
  25. {$DEFINE TypedReset}
  26. {$ENDIF VER_ABOVE0_9_5}
  27. {Str() is Intern from Version 0_9_7}
  28. {$IFDEF VER_ABOVE0_9_7}
  29. {$DEFINE str_intern}
  30. {$ENDIF VER_ABOVE0_9_7}
  31. { ------------------------- FLOATING POINT DEFINES ----------------------- }
  32. { possible conditionals here: }
  33. { comp_support = comp type supported. }
  34. { ieee_support = ieee support otherwise only real support possible. }
  35. {$ifdef i386}
  36. {$define comp_support}
  37. {$define ieee_support}
  38. {$endif}
  39. {****************************************************************************
  40. Global Types and Constants
  41. ****************************************************************************}
  42. Type
  43. {
  44. Longint is in TP declared as -2147483648..2147483647,
  45. But it can't be translated to Free Pascal, since the compiler
  46. first tries to convert 2147483648 to an integer constant
  47. and later ignores the number.
  48. But val can't use that...
  49. So, In 2 complement notation:
  50. }
  51. Longint = $80000000..$7fffffff;
  52. Integer = -32768..32767;
  53. shortint = -128..127;
  54. byte = 0..255;
  55. Word = 0..65535;
  56. { at least declare Turbo Pascal real types:}
  57. {$IFDEF i386}
  58. Double = real;
  59. {$ENDIF}
  60. {$IFNDEF VER_ABOVE0_9_2}
  61. Extended = real;
  62. single = real;
  63. comp = real;
  64. {$ELSE}
  65. {$DEFINE VER_HAS_EXTENDED}
  66. {$ENDIF VER_ABOVE0_9_2}
  67. {$IFDEF VER0_6}
  68. fixed = Longint;
  69. {$ENDIF}
  70. { some type aliases }
  71. {$IFDEF VER_ABOVE0_9_2}
  72. dword = cardinal;
  73. longword = cardinal;
  74. {$ENDIF VER_ABOVE0_9_2}
  75. { Zero - terminated strings }
  76. PChar = ^Char;
  77. PPChar = ^PChar;
  78. { procedure type }
  79. TProcedure = Procedure;
  80. const
  81. { max. values for longint and int}
  82. maxLongint = $7fffffff;
  83. maxint = 32767;
  84. { Compatibility With TP }
  85. {$ifdef i386}
  86. Test8086:byte = 2; { Always i386 or newer }
  87. Test8087:byte = 3; { Always 387 or newer. Emulated if needed. }
  88. {$endif i386}
  89. {$ifdef m68k}
  90. Test68000 : byte = 0; { Must be determined at startup for both }
  91. Test68881 : byte = 0;
  92. {$endif}
  93. { max level in dumping on error }
  94. Max_Frame_Dump:Word = 20;
  95. { Exit Procedure handling consts and types }
  96. Erroraddr:pointer = nil;
  97. Errorcode:Word = 0;
  98. { file input modes }
  99. fmClosed = $D7B0;
  100. fmInput = $D7B1;
  101. fmOutput = $D7B2;
  102. fmInOut = $D7B3;
  103. fmAppend = $D7B4;
  104. Filemode:byte = 2;
  105. var
  106. { Standard In- and Output }
  107. Output,
  108. Input,
  109. StdErr : Text;
  110. ExitProc : pointer;
  111. ExitCode : Word;
  112. {$IFDEF Win32}
  113. InOutRes : Longint;
  114. {$ELSE Win32}
  115. InOutRes : Word;
  116. {$ENDIF Win32}
  117. StackBottom,
  118. LowestStack,
  119. RandSeed : Longint;
  120. {****************************************************************************
  121. Processor specific routines
  122. ****************************************************************************}
  123. Procedure Move(Var source,dest;count:Longint);
  124. Procedure FillChar(Var x;count:Longint;Value:Char);
  125. Procedure FillChar(Var x;count:Longint;Value:byte);
  126. Procedure FillWord(Var x;count:Longint;Value:Word);
  127. {****************************************************************************
  128. Math Routines
  129. ****************************************************************************}
  130. Function lo(w:Word):byte;
  131. Function lo(l:Longint):Word;
  132. Function lo(i:Integer):byte;
  133. Function lo(B: Byte):Byte;
  134. Function hi(w:Word):byte;
  135. Function hi(i:Integer):byte;
  136. Function hi(l:Longint):Word;
  137. Function Hi(B : Byte): byte;
  138. Procedure Inc(Var i:cardinal);
  139. Procedure Inc(Var i:Longint);
  140. Procedure Inc(Var i:Integer);
  141. Procedure Inc(Var i:Word);
  142. Procedure Inc(Var i:shortint);
  143. Procedure Inc(Var i:byte);
  144. Procedure Inc(Var c:Char);
  145. Procedure Inc(Var p:PChar);
  146. Procedure Dec(Var i:cardinal);
  147. Procedure Dec(Var i:Longint);
  148. Procedure Dec(Var i:Integer);
  149. Procedure Dec(Var i:Word);
  150. Procedure Dec(Var i:shortint);
  151. Procedure Dec(Var i:byte);
  152. Procedure Dec(Var c:Char);
  153. Procedure Dec(Var p:PChar);
  154. {$IFNDEF ORDINTERN}
  155. Function Ord(c:Char):byte;
  156. Function Ord(b:Boolean):byte;
  157. {$ENDIF ORDINTERN}
  158. Function Chr(b:byte):Char;
  159. Function Length(s:string):byte;
  160. Procedure Dec(Var i:cardinal;a:Longint);
  161. Procedure Inc(Var i:cardinal;a:Longint);
  162. Procedure Dec(Var i:Longint;a:Longint);
  163. Procedure Inc(Var i:Longint;a:Longint);
  164. Procedure Dec(Var i:Word;a:Longint);
  165. Procedure Inc(Var i:Word;a:Longint);
  166. Procedure Dec(Var i:Integer;a:Longint);
  167. Procedure Inc(Var i:Integer;a:Longint);
  168. Procedure Dec(Var i:byte;a:Longint);
  169. Procedure Inc(Var i:byte;a:Longint);
  170. Procedure Dec(Var i:shortint;a:Longint);
  171. Procedure Inc(Var i:shortint;a:Longint);
  172. Procedure Dec(Var c:Char;a:Longint);
  173. Procedure Inc(Var c:Char;a:Longint);
  174. Procedure Dec(Var p:PChar;a:Longint);
  175. Procedure Inc(Var p:PChar;a:Longint);
  176. Function Swap (X:Word):Word;
  177. Function Swap (X:Integer):Integer;
  178. Function Swap (X:Cardinal):Cardinal;
  179. Function Swap (X:Longint):Longint;
  180. Function Random(l:Longint):Longint;
  181. Function Random:real;
  182. Procedure Randomize;
  183. Function abs(l:Longint):Longint;
  184. Function sqr(l:Longint):Longint;
  185. Function odd(l:Longint):Boolean;
  186. { float mathe routines }
  187. {$I mathh.inc}
  188. {****************************************************************************
  189. Memory management
  190. ****************************************************************************}
  191. Procedure getmem(Var p:pointer;Size:Longint);
  192. Procedure freemem(Var p:pointer;Size:Longint);
  193. Function memavail:Longint;
  194. Function maxavail:Longint;
  195. Function ptr(sel,off:Longint):pointer;
  196. Function Addr (Var X):pointer;
  197. Function Cseg:Word;
  198. Function Dseg:Word;
  199. Function Sseg:Word;
  200. {****************************************************************************
  201. String Handling
  202. ****************************************************************************}
  203. Function copy(const s:string;index:Integer;count:Integer):string;
  204. Procedure Delete(Var s:string;index:Integer;count:Integer);
  205. Procedure Insert(const source:string;Var s:string;index:Integer);
  206. Function Pos(const substr:string;const s:string):byte;
  207. Function Pos(C:Char;const s:string):byte;
  208. Function upCase(c:Char):Char;
  209. Function upCase(const s:string):string;
  210. Function lowerCase(c:Char):Char;
  211. Function lowerCase(const s:string):string;
  212. Function Space(b:byte):string;
  213. Function hexStr(Val:Longint;cnt:byte):string;
  214. Function binStr(Val:Longint;cnt:byte):string;
  215. {$IFNDEF STR_INTERN}
  216. Procedure Str(l:Longint;Var s:string);
  217. {$ifdef support_ieee}
  218. Procedure Str(d:Double;Var s : string);
  219. {$endif support_ieee}
  220. {$ifndef support_ieee}
  221. Procedure Str(d : real;Var s : string);
  222. {$endif support_ieee}
  223. Procedure Str(i:Integer;Var s:string);
  224. Procedure Str(si:shortint;Var s:string);
  225. Procedure Str(b:byte;Var s:string);
  226. Procedure Str(w:Word;Var s:string);
  227. {$ENDIF STR_INTERN}
  228. Procedure Val(const s:string;Var v:Longint;Var code:Word);
  229. Procedure Val(const s:string;Var l:Longint;Var code:Integer);
  230. Procedure Val(const s:string;Var l:Longint);
  231. Procedure Val(const s:string;Var b:byte;Var code:Word);
  232. Procedure Val(const s:string;Var b:byte;Var code:Integer);
  233. Procedure Val(const s:string;Var b:byte);
  234. Procedure Val(const s:string;Var b:shortint;Var code:Word);
  235. Procedure Val(const s:string;Var b:shortint;Var code:Integer);
  236. Procedure Val(const s:string;Var b:shortint);
  237. Procedure Val(const s:string;Var b:Word;Var code:Word);
  238. Procedure Val(const s:string;Var b:Word;Var code:Integer);
  239. Procedure Val(const s:string;Var b:Word);
  240. Procedure Val(const s:string;Var b:Integer;Var code:Word);
  241. Procedure Val(const s:string;Var b:Integer;Var code:Integer);
  242. Procedure Val(const s:string;Var b:Integer);
  243. Procedure Val(const s:string;Var d:Real;Var code:Word);
  244. Procedure Val(const s:string;Var d:Real;Var code:Integer);
  245. Procedure Val(const s:string;Var d:Real);
  246. {$IFDEF VER_ABOVE0_9_2}
  247. {$IFDEF ieee_support}
  248. Procedure Val(const s:string;Var d:single;Var code:Word);
  249. Procedure Val(const s:string;Var d:single;Var code:Integer);
  250. Procedure Val(const s:string;Var d:single);
  251. {$ENDIF ieee_support}
  252. {$ENDIF VER_ABOVE0_9_2}
  253. {$IFDEF VER_ABOVE0_9_7}
  254. {$IFDEF ieee_support}
  255. Procedure Val(const s:string;Var d:Extended;Var code:Word);
  256. Procedure Val(const s:string;Var d:Extended;Var code:Integer);
  257. Procedure Val(const s:string;Var d:Extended);
  258. {$ENDIF ieee_support}
  259. {$IFDEF comp_support}
  260. Procedure Val(const s:string;Var d:comp;Var code:Word);
  261. Procedure Val(const s:string;Var d:comp;Var code:Integer);
  262. Procedure Val(const s:string;Var d:comp);
  263. {$ENDIF comp_support}
  264. {$ENDIF VER_ABOVE0_9_7}
  265. {$IFDEF VER_ABOVE0_9_8}
  266. Procedure Val(const s:string;Var v:cardinal;Var code:Word);
  267. Procedure Val(const s:string;Var v:cardinal;Var code:Integer);
  268. Procedure Val(const s:string;Var v:cardinal);
  269. {$ENDIF VER_ABOVE0_9_8}
  270. {****************************************************************************
  271. Untyped File Management
  272. ****************************************************************************}
  273. Procedure Assign(Var f:File;const Name:string);
  274. Procedure Rewrite(Var f:File;l:Word);
  275. Procedure Rewrite(Var f:File);
  276. Procedure Reset(Var f:File;l:Word);
  277. Procedure Reset(Var f:File);
  278. Procedure Close(Var f:File);
  279. Procedure BlockWrite(Var f:File;Var Buf;Count:Longint;Var Result:Longint);
  280. Procedure BlockWrite(Var f:File;Var Buf;Count:Word;Var Result:Word);
  281. Procedure BlockWrite(Var f:File;Var Buf;Count:Word;Var Result:Integer);
  282. Procedure BlockWrite(Var f:File;Var Buf;Count:Longint);
  283. Procedure BlockRead(Var f:File;Var Buf;count:Longint;Var Result:Longint);
  284. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Word);
  285. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Integer);
  286. Procedure BlockRead(Var f:File;Var Buf;count:Longint);
  287. Function FilePos(Var f:File):Longint;
  288. Function FileSize(Var f:File):Longint;
  289. Procedure Seek(Var f:File;Pos:Longint);
  290. Function EOF(Var f:File):Boolean;
  291. Procedure Erase(Var f:File);
  292. Procedure Rename(Var f:File;const s:string);
  293. Procedure Truncate (Var F:File);
  294. {****************************************************************************
  295. Typed File Management
  296. ****************************************************************************}
  297. {$IFDEF TypedFile}
  298. Procedure Assign(Var f:TypedFile;const Name:string);
  299. Procedure Rewrite(Var f:TypedFile);
  300. Procedure Reset(Var f:TypedFile);
  301. {$ENDIF TypedFile}
  302. {****************************************************************************
  303. Text File Management
  304. ****************************************************************************}
  305. Procedure Assign(Var t:Text;const s:string);
  306. Procedure Close(Var t:Text);
  307. Procedure Rewrite(Var t:Text);
  308. Procedure Reset(Var t:Text);
  309. Procedure Append(Var t:Text);
  310. Procedure Flush(Var t:Text);
  311. Procedure Erase(Var t:Text);
  312. Procedure Rename(Var t:Text;const s:string);
  313. Function EOF(Var t:Text):Boolean;
  314. Function EOF:Boolean;
  315. Function EOLn(Var t:Text):Boolean;
  316. Function EOLn:Boolean;
  317. Function SeekEOLn (Var F:Text):Boolean;
  318. Function SeekEOF (Var F:Text):Boolean;
  319. Function SeekEOLn:Boolean;
  320. Function SeekEOF:Boolean;
  321. Procedure SetTextBuf(Var f:Text; Var Buf);
  322. Procedure SetTextBuf(Var f:Text; Var Buf; Size:Word);
  323. {****************************************************************************
  324. Directory Management
  325. ****************************************************************************}
  326. Procedure chdir(const s:string);
  327. Procedure mkdir(const s:string);
  328. Procedure rmdir(const s:string);
  329. Procedure getdir(drivenr:byte;Var dir:string);
  330. {*****************************************************************************
  331. Miscelleaous
  332. *****************************************************************************}
  333. Function IOResult:Word;
  334. Function Sptr:Longint;
  335. {****************************************************************************
  336. The whole Delphi stuff is in the unit objpas
  337. *****************************************************************************}
  338. {*****************************************************************************
  339. Init / Exit / ExitProc
  340. *****************************************************************************}
  341. Function Paramcount:Longint;
  342. Function ParamStr(l:Longint):string;
  343. Procedure Dump_Stack(bp:Longint);
  344. Procedure RunError(w:Word);
  345. Procedure RunError;
  346. Procedure halt(errnum:byte);
  347. Procedure halt;
  348. Procedure AddExitProc(Proc:TProcedure);
  349. {
  350. $Log$
  351. Revision 1.4 1998-04-16 12:30:47 peter
  352. + inc(pchar), dec(pchar), incc(pchar,a),dec(pchar,a)
  353. Revision 1.3 1998/03/26 14:41:22 michael
  354. + Added comp support for val and read(ln)
  355. Revision 1.2 1998/03/25 23:39:17 florian
  356. * complete Object Pascal support moved to objpas unit
  357. Revision 1.1.1.1 1998/03/25 11:18:43 root
  358. * Restored version
  359. Revision 1.22 1998/03/24 15:50:25 peter
  360. + dword,longword=cardinal (for > 0.9.2 unlike Florian did with longword)
  361. Revision 1.21 1998/03/05 02:42:30 peter
  362. + blockread/blockwrite with integer result
  363. Revision 1.20 1998/03/04 14:22:07 florian
  364. + longword is synonyme for cardinal
  365. Revision 1.19 1998/01/26 11:59:57 michael
  366. + Added log at the end
  367. Working file: rtl/inc/systemh.inc
  368. description:
  369. ----------------------------
  370. revision 1.18
  371. date: 1998/01/23 22:21:48; author: michael; state: Exp; lines: +12 -1
  372. + Set up things for Delphi Object model under DELPHI_EXTENSIONS
  373. ----------------------------
  374. revision 1.17
  375. date: 1998/01/23 15:30:45; author: michael; state: Exp; lines: +2 -2
  376. * Daniel forgot to adapt systemh to changes he made in sstrings.inc.
  377. ----------------------------
  378. revision 1.16
  379. date: 1998/01/20 09:14:36; author: michael; state: Exp; lines: +3 -1
  380. + implemented Hi and Lo for bytes. SHould be made an internalproc, though.
  381. ----------------------------
  382. revision 1.15
  383. date: 1998/01/16 17:58:51; author: florian; state: Exp; lines: +3 -2
  384. * basic tobject added (create, destroy and free)
  385. ----------------------------
  386. revision 1.14
  387. date: 1998/01/12 02:32:58; author: carl; state: Exp; lines: +40 -12
  388. + now works with sysatari
  389. ----------------------------
  390. revision 1.13
  391. date: 1998/01/11 02:45:43; author: michael; state: Exp; lines: +341 -459
  392. + Moved file operations to
  393. - file.inc : Untyped file handling
  394. - text.inc text file handling
  395. - typefile.inc typed file handling
  396. - version stuff to version.inc
  397. By Peter Vreman.
  398. ----------------------------
  399. revision 1.12
  400. date: 1998/01/05 12:37:11; author: michael; state: Exp; lines: +19 -30
  401. + undid changes by Carl, they rendered the system unit useless.
  402. ----------------------------
  403. revision 1.11
  404. date: 1998/01/05 00:47:55; author: carl; state: Exp; lines: +30 -19
  405. + Now compatible with m68k floating point types
  406. ----------------------------
  407. revision 1.10
  408. date: 1998/01/01 16:56:09; author: michael; state: Exp; lines: +8 -1
  409. + Implemented Addr() function.
  410. + Implemented Inc/Dec for cardinal
  411. + Implemented Inc/Dec (C : Char; A : longint);
  412. ----------------------------
  413. revision 1.9
  414. date: 1997/12/24 14:25:16; author: michael; state: Exp; lines: +2 -1
  415. + Added SSEG function (From Peter Vreman)
  416. ----------------------------
  417. revision 1.8
  418. date: 1997/12/23 16:33:21; author: michael; state: Exp; lines: +6 -3
  419. + Added dec() and inc() for char (from Peter Vreman)
  420. ----------------------------
  421. revision 1.7
  422. date: 1997/12/22 15:34:37; author: michael; state: Exp; lines: +3 -2
  423. + added faster pos (const char; ..) seeking.
  424. ----------------------------
  425. revision 1.6
  426. date: 1997/12/13 19:02:14; author: florian; state: Exp; lines: +26 -2
  427. + defines for version 0.99.0
  428. ----------------------------
  429. revision 1.5
  430. date: 1997/12/11 13:52:21; author: florian; state: Exp; lines: +11 -1
  431. *** empty log message ***
  432. ----------------------------
  433. revision 1.4
  434. date: 1997/12/11 11:49:48; author: michael; state: Exp; lines: +2 -1
  435. + added comp type for versions below 0.9.1.
  436. ----------------------------
  437. revision 1.3
  438. date: 1997/12/01 12:08:05; author: michael; state: Exp; lines: +11 -4
  439. + added copyright reference header.
  440. ----------------------------
  441. revision 1.2
  442. date: 1997/11/27 16:29:38; author: michael; state: Exp; lines: +3 -1
  443. Change submitted by Pierre Muller:
  444. Added check : version must be above 0.9.7 for extended type
  445. handling functions.
  446. ----------------------------
  447. revision 1.1
  448. date: 1997/11/27 08:33:47; author: michael; state: Exp;
  449. Initial revision
  450. ----------------------------
  451. revision 1.1.1.1
  452. date: 1997/11/27 08:33:47; author: michael; state: Exp; lines: +0 -0
  453. FPC RTL CVS start
  454. =============================================================================
  455. }