system.pp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2004 by Karoly Balogh for Genesi Sarl
  5. System unit for MorphOS.
  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. { These things are set in the makefile, }
  13. { But you can override them here.}
  14. { If you use an aout system, set the conditional AOUT}
  15. { $Define AOUT}
  16. Unit {$ifdef VER1_0}Sysmorph{$else}System{$endif};
  17. Interface
  18. {$define FPC_IS_SYSTEM}
  19. {$I sysunixh.inc}
  20. Implementation
  21. {$I system.inc}
  22. { OS dependant parts }
  23. {$I errno.inc} // error numbers
  24. {$I bunxtype.inc} // c-types, unix base types, unix
  25. // base structures
  26. {$I ossysc.inc} // base syscalls
  27. {$I osmain.inc} // base wrappers *nix RTL (derivatives)
  28. { more OS independant parts}
  29. {$I text.inc}
  30. {$I heap.inc}
  31. {*****************************************************************************
  32. UnTyped File Handling
  33. *****************************************************************************}
  34. {$i file.inc}
  35. {*****************************************************************************
  36. Typed File Handling
  37. *****************************************************************************}
  38. {$i typefile.inc}
  39. procedure SysInitStdIO;
  40. begin
  41. OpenStdIO(Input,fmInput,StdInputHandle);
  42. OpenStdIO(Output,fmOutput,StdOutputHandle);
  43. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  44. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  45. end;
  46. procedure SysInitExecPath;
  47. var
  48. hs : string[16];
  49. link : string;
  50. i : longint;
  51. begin
  52. str(Fpgetpid,hs);
  53. hs:='/proc/'+hs+'/exe'#0;
  54. i:=Fpreadlink(@hs[1],@link[1],high(link));
  55. { it must also be an absolute filename, linux 2.0 points to a memory
  56. location so this will skip that }
  57. if (i>0) and (link[1]='/') then
  58. begin
  59. link[0]:=chr(i);
  60. ExecPathStr:=link;
  61. end;
  62. end;
  63. Begin
  64. IsConsole := TRUE;
  65. IsLibrary := FALSE;
  66. StackLength := InitialStkLen;
  67. StackBottom := Sptr - StackLength;
  68. { Set up signals handlers }
  69. InstallSignals;
  70. { Setup heap }
  71. InitHeap;
  72. SysInitExceptions;
  73. { Arguments }
  74. SetupCmdLine;
  75. SysInitExecPath;
  76. { Setup stdin, stdout and stderr }
  77. SysInitStdIO;
  78. { Reset IO Error }
  79. InOutRes:=0;
  80. (* This should be changed to a real value during *)
  81. (* thread driver initialization if appropriate. *)
  82. ThreadID := 1;
  83. {$ifdef HASVARIANT}
  84. initvariantmanager;
  85. {$endif HASVARIANT}
  86. End.
  87. {
  88. $Log$
  89. Revision 1.1 2004-02-13 07:19:53 karoly
  90. * quick hack from Linux system unit
  91. }