system.pp 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by the Free Pascal development team.
  5. This is a prototype file to show all function that need to be implemented
  6. for a new operating system (provided the processor specific
  7. function are already implemented !)
  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. { no stack check in system }
  15. {$S-}
  16. unit system;
  17. interface
  18. { include system-independent routine headers }
  19. {$I systemh.inc}
  20. type
  21. THandle = longint;
  22. { include heap support headers }
  23. {$I heaph.inc}
  24. {Platform specific information}
  25. const
  26. LineEnding = #13#10;
  27. LFNSupport = true;
  28. DirectorySeparator = '\';
  29. DriveSeparator = ':';
  30. PathSeparator = ';';
  31. FileNameCaseSensitive = false;
  32. {The highest exit code which can be returned to the operating system.
  33. Should be at least 255.}
  34. maxExitCode = 255;
  35. const
  36. UnusedHandle = -1;
  37. StdInputHandle = 0;
  38. StdOutputHandle = 1;
  39. StdErrorHandle = 2;
  40. sLineBreak : string[1] = LineEnding;
  41. DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsLF;
  42. var
  43. argc : longint;
  44. argv : ppchar;
  45. envp : ppchar;
  46. implementation
  47. { include system independent routines }
  48. {$I system.inc}
  49. procedure setup_arguments;
  50. begin
  51. end;
  52. procedure setup_environment;
  53. begin
  54. end;
  55. function GetProcessID: SizeUInt;
  56. begin
  57. end;
  58. {*****************************************************************************
  59. System Dependent Exit code
  60. *****************************************************************************}
  61. Procedure system_exit;
  62. begin
  63. end;
  64. {*****************************************************************************
  65. ParamStr/Randomize
  66. *****************************************************************************}
  67. { number of args }
  68. function paramcount : longint;
  69. begin
  70. {paramcount := argc - 1;}
  71. paramcount:=0;
  72. end;
  73. { argument number l }
  74. function paramstr(l : longint) : string;
  75. begin
  76. {if (l>=0) and (l+1<=argc) then
  77. paramstr:=strpas(argv[l])
  78. else}
  79. paramstr:='';
  80. end;
  81. { set randseed to a new pseudo random value }
  82. procedure randomize;
  83. begin
  84. {regs.realeax:=$2c00;
  85. sysrealintr($21,regs);
  86. hl:=regs.realedx and $ffff;
  87. randseed:=hl*$10000+ (regs.realecx and $ffff);}
  88. randseed:=0;
  89. end;
  90. {*****************************************************************************
  91. OS Memory allocation / deallocation
  92. ****************************************************************************}
  93. function SysOSAlloc(size: ptrint): pointer;
  94. begin
  95. // code to allocate memory block
  96. end;
  97. // If the OS is capable of freeing memory, define HAS_SYSOSFREE and implement
  98. // the SysOSFree function properly
  99. //{$define HAS_SYSOSFREE}
  100. {
  101. procedure SysOSFree(p: pointer; size: ptrint);
  102. begin
  103. // code to release memory block
  104. end;
  105. }
  106. { include standard heap management }
  107. {$I heap.inc}
  108. {****************************************************************************
  109. Low level File Routines
  110. All these functions can set InOutRes on errors
  111. ****************************************************************************}
  112. { close a file from the handle value }
  113. procedure do_close(handle : longint);
  114. begin
  115. InOutRes:=1;
  116. end;
  117. procedure do_erase(p : pchar);
  118. begin
  119. InOutRes:=1;
  120. end;
  121. procedure do_rename(p1,p2 : pchar);
  122. begin
  123. InOutRes:=1;
  124. end;
  125. function do_write(h,addr,len : longint) : longint;
  126. begin
  127. InOutRes:=1;
  128. end;
  129. function do_read(h,addr,len : longint) : longint;
  130. begin
  131. InOutRes:=1;
  132. end;
  133. function do_filepos(handle : longint) : longint;
  134. begin
  135. InOutRes:=1;
  136. end;
  137. procedure do_seek(handle,pos : longint);
  138. begin
  139. InOutRes:=1;
  140. end;
  141. function do_seekend(handle:longint):longint;
  142. begin
  143. InOutRes:=1;
  144. end;
  145. function do_filesize(handle : longint) : longint;
  146. begin
  147. InOutRes:=1;
  148. end;
  149. { truncate at a given position }
  150. procedure do_truncate (handle,pos:longint);
  151. begin
  152. InOutRes:=1;
  153. end;
  154. procedure do_open(var f;p:pchar;flags:longint);
  155. {
  156. filerec and textrec have both handle and mode as the first items so
  157. they could use the same routine for opening/creating.
  158. when (flags and $10) the file will be append
  159. when (flags and $100) the file will be truncate/rewritten
  160. when (flags and $1000) there is no check for close (needed for textfiles)
  161. }
  162. begin
  163. InOutRes:=1;
  164. end;
  165. function do_isdevice(handle:longint):boolean;
  166. begin
  167. do_isdevice:=false;
  168. end;
  169. {*****************************************************************************
  170. UnTyped File Handling
  171. *****************************************************************************}
  172. {$i file.inc}
  173. {*****************************************************************************
  174. Typed File Handling
  175. *****************************************************************************}
  176. {$i typefile.inc}
  177. {*****************************************************************************
  178. Text File Handling
  179. *****************************************************************************}
  180. { should we consider #26 as the end of a file ? }
  181. {?? $DEFINE EOF_CTRLZ}
  182. {$i text.inc}
  183. {*****************************************************************************
  184. Directory Handling
  185. *****************************************************************************}
  186. procedure mkdir(const s : string);[IOCheck];
  187. begin
  188. InOutRes:=1;
  189. end;
  190. procedure rmdir(const s : string);[IOCheck];
  191. begin
  192. InOutRes:=1;
  193. end;
  194. procedure chdir(const s : string);[IOCheck];
  195. begin
  196. InOutRes:=1;
  197. end;
  198. procedure GetDir (DriveNr: byte; var Dir: ShortString);
  199. begin
  200. InOutRes := 1;
  201. end;
  202. {*****************************************************************************
  203. SystemUnit Initialization
  204. *****************************************************************************}
  205. Begin
  206. { To be set if this is a GUI or console application }
  207. IsConsole := TRUE;
  208. { To be set if this is a library and not a program }
  209. IsLibrary := FALSE;
  210. StackBottom := SPtr - StackLength;
  211. ExitCode := 0;
  212. { Setup heap }
  213. InitHeap;
  214. { Setup stdin, stdout and stderr }
  215. OpenStdIO(Input,fmInput,StdInputHandle);
  216. OpenStdIO(Output,fmOutput,StdOutputHandle);
  217. OpenStdIO(ErrOutput,fmOutput,StdErrorHandle);
  218. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  219. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  220. { Setup environment and arguments }
  221. Setup_Environment;
  222. Setup_Arguments;
  223. { Reset IO Error }
  224. InOutRes:=0;
  225. (* This should be changed to a real value during *)
  226. (* thread driver initialization if appropriate. *)
  227. ThreadID := 1;
  228. End.
  229. {
  230. $Log$
  231. Revision 1.15 2004-12-05 14:36:38 hajny
  232. + GetProcessID added
  233. Revision 1.14 2004/11/04 09:32:31 peter
  234. ErrOutput added
  235. Revision 1.13 2004/10/25 15:38:59 peter
  236. * compiler defined HEAP and HEAPSIZE removed
  237. Revision 1.12 2004/09/03 19:26:57 olle
  238. + added maxExitCode to all System.pp
  239. * constrained error code to be below maxExitCode in RunError et. al.
  240. Revision 1.11 2004/06/17 16:16:14 peter
  241. * New heapmanager that releases memory back to the OS, donated
  242. by Micha Nelissen
  243. Revision 1.10 2004/01/20 23:12:49 hajny
  244. * ExecuteProcess fixes, ProcessID and ThreadID added
  245. Revision 1.9 2003/09/27 11:52:36 peter
  246. * sbrk returns pointer
  247. Revision 1.8 2002/09/07 16:01:27 peter
  248. * old logs removed and tabs fixed
  249. Revision 1.7 2002/04/21 15:55:14 carl
  250. + initialize some global variables
  251. }