system.pp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time librar~y.
  4. Copyright (c) 2000 by Marco van de Voort
  5. member of the Free Pascal development team.
  6. System unit for the *BSD's.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. { These things are set in the makefile, }
  14. { But you can override them here.}
  15. { If you use an aout system, set the conditional AOUT}
  16. { $Define AOUT}
  17. Unit {$ifdef VER1_0}SysBSD{$else}System{$endif};
  18. Interface
  19. {$define FPC_USE_SIGPROCMASK}
  20. {$define FPC_USE_SIGALTSTACK}
  21. {$ifndef FPC_USE_LIBC}
  22. {$define FPC_USE_SYSCALL}
  23. {$endif}
  24. {$define FPC_IS_SYSTEM}
  25. {$I sysunixh.inc}
  26. {$ifdef Darwin}
  27. var argc:cardinal;
  28. argv:PPchar;
  29. envp:PPchar;
  30. {$endif}
  31. CONST SIGSTKSZ = 40960;
  32. Implementation
  33. {$I system.inc}
  34. procedure SysInitStdIO;
  35. begin
  36. OpenStdIO(Input,fmInput,StdInputHandle);
  37. OpenStdIO(Output,fmOutput,StdOutputHandle);
  38. OpenStdIO(ErrOutput,fmOutput,StdErrorHandle);
  39. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  40. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  41. end;
  42. {$ifdef FPC_USE_LIBC}
  43. { can also be used with other BSD's if they use the system's crtX instead of prtX }
  44. {$ifdef Darwin}
  45. procedure pascalmain; external name 'PASCALMAIN';
  46. { Main entry point in C style, needed to capture program parameters. }
  47. procedure main(argcparam: Longint; argvparam: ppchar; envpparam: ppchar); cdecl; [public];
  48. begin
  49. argc:= argcparam;
  50. argv:= argvparam;
  51. envp:= envpparam;
  52. pascalmain; {run the pascal main program}
  53. end;
  54. {$endif Darwin}
  55. {$endif FPC_USE_LIBC}
  56. function GetProcessID: SizeUInt;
  57. begin
  58. GetProcessID := SizeUInt (fpGetPID);
  59. end;
  60. Begin
  61. IsConsole := TRUE;
  62. IsLibrary := FALSE;
  63. StackLength := InitialStkLen;
  64. StackBottom := Sptr - StackLength;
  65. { Set up signals handlers }
  66. InstallSignals;
  67. { Setup heap }
  68. InitHeap;
  69. SysInitExceptions;
  70. { Arguments }
  71. SetupCmdLine;
  72. { Setup stdin, stdout and stderr }
  73. SysInitStdIO;
  74. { Reset IO Error }
  75. InOutRes:=0;
  76. { threading }
  77. InitSystemThreads;
  78. {$ifdef HASVARIANT}
  79. initvariantmanager;
  80. {$endif HASVARIANT}
  81. {$ifdef HASWIDESTRING}
  82. initwidestringmanager;
  83. {$endif HASWIDESTRING}
  84. End.
  85. {
  86. $Log$
  87. Revision 1.23 2005-02-06 12:16:52 peter
  88. * bsd thread updates
  89. Revision 1.22 2005/02/01 20:22:49 florian
  90. * improved widestring infrastructure manager
  91. Revision 1.21 2004/12/05 14:36:37 hajny
  92. + GetProcessID added
  93. Revision 1.20 2004/11/04 09:32:31 peter
  94. ErrOutput added
  95. Revision 1.19 2004/07/17 15:31:03 jonas
  96. * initialise StackLength (fixes stack checking in general, and tw2897 in
  97. particular)
  98. Revision 1.18 2004/07/03 22:49:34 daniel
  99. * Moved declarations downwards
  100. Revision 1.17 2004/07/03 22:44:37 daniel
  101. * Declared envp,argc,argv in interface for Darwin
  102. Revision 1.16 2004/06/19 08:06:04 marco
  103. * moved heap.inc and text.inc before sysalloc as suggested. Why wasn't this
  104. done directly?
  105. Revision 1.15 2004/06/17 16:16:13 peter
  106. * New heapmanager that releases memory back to the OS, donated
  107. by Micha Nelissen
  108. Revision 1.14 2004/01/22 13:46:14 marco
  109. bsd
  110. Revision 1.13 2004/01/20 23:09:14 hajny
  111. * ExecuteProcess fixes, ProcessID and ThreadID added
  112. Revision 1.12 2004/01/04 20:32:05 jonas
  113. + geterrnolocation for Darwin
  114. + C-style main for Darwin (generic, can be used for anything)
  115. Revision 1.11 2003/12/30 12:26:21 marco
  116. * FPC_USE_LIBC
  117. Revision 1.10 2003/10/26 17:01:04 marco
  118. * moved sigprocmask to system
  119. Revision 1.9 2003/10/26 16:42:22 marco
  120. * texception4 fix merge
  121. Revision 1.8 2003/01/05 19:01:28 marco
  122. * FreeBSD compiles now with baseunix mods.
  123. Revision 1.7 2002/11/12 14:57:48 marco
  124. * Ugly hack to temporarily be able to use system.pp for Linux too
  125. Revision 1.6 2002/10/27 11:58:30 marco
  126. * Modifications from Saturday.
  127. Revision 1.5 2002/10/26 18:27:51 marco
  128. * First series POSIX calls commits. Including getcwd.
  129. Revision 1.4 2002/10/18 12:19:58 marco
  130. * Fixes to get the generic *BSD RTL compiling again + fixes for thread
  131. support. Still problems left in fexpand. (inoutres?) Therefore fixed
  132. sysposix not yet commited
  133. Revision 1.3 2002/10/13 09:25:39 florian
  134. + call to initvariantmanager inserted
  135. Revision 1.2 2002/09/07 16:01:17 peter
  136. * old logs removed and tabs fixed
  137. Revision 1.1 2002/08/19 12:29:11 marco
  138. * First working POSIX *BSD system unit.
  139. }