system.pp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. Solaris 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. unit System;
  13. interface
  14. { include system-independent routine headers }
  15. {$I sysunixh.inc}
  16. implementation
  17. var
  18. Errno : longint; external name 'errno'; { declared in libc }
  19. { OS independant parts}
  20. {$I system.inc}
  21. {*****************************************************************************
  22. OS Memory allocation / deallocation
  23. ****************************************************************************}
  24. { OS dependant parts }
  25. {$I errno.inc}
  26. {$I bunxtype.inc}
  27. {$I osposix.inc}
  28. {$I sysposix.inc}
  29. function SysOSAlloc(size: ptrint): pointer;
  30. begin
  31. // result := sbrk(size);
  32. end;
  33. {$define HAS_SYSOSFREE}
  34. procedure SysOSFree(p: pointer; size: ptrint);
  35. begin
  36. // fpmunmap(p, size);
  37. end;
  38. function do_isdevice(handle:longint):boolean;
  39. begin
  40. do_isdevice:= (handle=StdInputHandle) or
  41. (handle=StdOutputHandle) or
  42. (handle=StdErrorHandle);
  43. end;
  44. {$I text.inc}
  45. {$I heap.inc}
  46. {*****************************************************************************
  47. UnTyped File Handling
  48. *****************************************************************************}
  49. {$i file.inc}
  50. {*****************************************************************************
  51. Typed File Handling
  52. *****************************************************************************}
  53. {$i typefile.inc}
  54. procedure SysInitStdIO;
  55. begin
  56. OpenStdIO(Input,fmInput,StdInputHandle);
  57. OpenStdIO(Output,fmOutput,StdOutputHandle);
  58. OpenStdIO(ErrOutput,fmOutput,StdErrorHandle);
  59. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  60. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  61. end;
  62. function GetProcessID: SizeUInt;
  63. begin
  64. GetProcessID := SizeUInt (fpGetPID);
  65. end;
  66. procedure pascalmain; external name 'PASCALMAIN';
  67. { Main entry point in C style, needed to capture program parameters. }
  68. procedure main(argcparam: Longint; argvparam: ppchar; envpparam: ppchar); cdecl; [public];
  69. begin
  70. argc:= argcparam;
  71. argv:= argvparam;
  72. envp:= envpparam;
  73. pascalmain; {run the pascal main program}
  74. end;
  75. Begin
  76. IsConsole := TRUE;
  77. IsLibrary := FALSE;
  78. StackLength := InitialStkLen;
  79. StackBottom := Sptr - StackLength;
  80. { Set up signals handlers }
  81. InstallSignals;
  82. { Setup heap }
  83. InitHeap;
  84. SysInitExceptions;
  85. { Arguments }
  86. SetupCmdLine;
  87. { Setup stdin, stdout and stderr }
  88. SysInitStdIO;
  89. { Reset IO Error }
  90. InOutRes:=0;
  91. (* This should be changed to a real value during *)
  92. (* thread driver initialization if appropriate. *)
  93. ThreadID := 1;
  94. {$ifdef HASVARIANT}
  95. initvariantmanager;
  96. {$endif HASVARIANT}
  97. End.
  98. {
  99. $Log$
  100. Revision 1.3 2004-12-05 14:36:38 hajny
  101. + GetProcessID added
  102. Revision 1.2 2004/11/06 22:22:28 florian
  103. * some sunos stuff from 1.0.x merged
  104. }