doslib.pp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2004 Karoly Balogh for Genesi S.a.r.l. <www.genesi.lu>
  5. dos.library interface unit for MorphOS/PowerPC
  6. MorphOS port was done on a free Pegasos II/G4 machine
  7. provided by Genesi S.a.r.l. <www.genesi.lu>
  8. See the file COPYING.FPC, included in this distribution,
  9. for details about the copyright.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. **********************************************************************}
  14. {$INLINE ON}
  15. unit doslib;
  16. interface
  17. uses Exec, Timer;
  18. var
  19. DosBase: Pointer;
  20. {$include doslibd.inc}
  21. {$include doslibf.inc}
  22. { * dos global definitions (V50)
  23. *********************************************************************
  24. * }
  25. function BADDR(x: LongInt): Pointer; Inline;
  26. function MKBADDR(x: Pointer): LongInt; Inline;
  27. { * dos stdio definitions
  28. *********************************************************************
  29. * }
  30. function ReadChar: LongInt; Inline;
  31. function WriteChar(ch: Char): LongInt; Inline;
  32. function UnReadChar(ch: Char): LongInt; Inline;
  33. function ReadChars(buf: Pointer; num: LongInt): LongInt; Inline;
  34. function dosReadLn(buf: PChar; num: LongInt): PChar; Inline;
  35. function WriteStr(str: PChar): LongInt; Inline;
  36. procedure VWritef(format: PChar; argv: Pointer); Inline;
  37. { * calls with tags workarounds (should be removed later)
  38. *********************************************************************
  39. * }
  40. function CreateNewProcTags(tags: array of dword): PProcess; Inline;
  41. implementation
  42. { * dos stdio definitions
  43. *********************************************************************
  44. * }
  45. function ReadChar: LongInt; Inline;
  46. begin
  47. ReadChar:=FGetC(dosInput);
  48. end;
  49. function WriteChar(ch: Char): LongInt; Inline;
  50. begin
  51. WriteChar:=FPutC(dosOutput,Byte(ch));
  52. end;
  53. function UnReadChar(ch: Char): LongInt; Inline;
  54. begin
  55. UnReadChar:=UnGetC(dosInput,Byte(ch));
  56. end;
  57. function ReadChars(buf: Pointer; num: LongInt): LongInt; Inline;
  58. begin
  59. ReadChars:=FRead(dosInput,buf,1,num);
  60. end;
  61. function dosReadLn(buf: PChar; num: LongInt): PChar; Inline;
  62. begin
  63. dosReadLn:=FGets(dosInput,buf,num);
  64. end;
  65. function WriteStr(str: PChar): LongInt; Inline;
  66. begin
  67. WriteStr:=FPuts(dosOutput,str);
  68. end;
  69. procedure VWritef(format: PChar; argv: Pointer); Inline;
  70. begin
  71. VFWritef(dosOutput,format,argv);
  72. end;
  73. { * dos global definitions (V50)
  74. *********************************************************************
  75. * }
  76. function BADDR(x: LongInt): Pointer; Inline;
  77. begin
  78. BADDR:=Pointer(x Shl 2);
  79. end;
  80. function MKBADDR(x: Pointer): LongInt; Inline;
  81. begin
  82. MKBADDR:=LongInt(x) Shr 2;
  83. end;
  84. { * calls with tags workarounds (should be removed later)
  85. *********************************************************************
  86. * }
  87. function CreateNewProcTags(tags: array of DWord): PProcess; Inline;
  88. begin
  89. CreateNewProcTags:=CreateNewProc(@tags);
  90. end;
  91. begin
  92. DosBase:=MOS_DOSBase;
  93. end.
  94. {
  95. $Log$
  96. Revision 1.4 2004-12-10 12:50:35 karoly
  97. * more ugly workarounds until compiler gets updated
  98. Revision 1.3 2004/08/09 12:57:07 karoly
  99. + added {$INLINE ON} to fix cycle
  100. Revision 1.2 2004/08/09 00:10:19 karoly
  101. + added most of missing stuff
  102. Revision 1.1 2004/06/26 20:46:17 karoly
  103. * initial revision
  104. }