system.pp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. CONST SIGSTKSZ = 40960;
  27. Implementation
  28. {$ifdef FPC_USE_LIBC}
  29. const clib = 'c';
  30. type libcint=longint;
  31. plibcint=^libcint;
  32. {$ifdef FreeBSD} // tested on x86
  33. function geterrnolocation: Plibcint; cdecl;external clib name '__error';
  34. {$else}
  35. {$ifdef NetBSD} // from a sparc dump.
  36. function geterrnolocation: Plibcint; cdecl;external clib name '__errno';
  37. {$else}
  38. {$endif}
  39. {$endif}
  40. function geterrno:libcint; [public, alias: 'FPC_SYS_GETERRNO'];
  41. begin
  42. geterrno:=geterrnolocation^;
  43. end;
  44. procedure seterrno(err:libcint); [public, alias: 'FPC_SYS_SETERRNO'];
  45. begin
  46. geterrnolocation^:=err;
  47. end;
  48. {$else}
  49. {$ifdef ver1_0}
  50. Var
  51. {$else}
  52. threadvar
  53. {$endif}
  54. Errno : longint;
  55. function geterrno:longint; [public, alias: 'FPC_SYS_GETERRNO'];
  56. begin
  57. GetErrno:=Errno;
  58. end;
  59. procedure seterrno(err:longint); [public, alias: 'FPC_SYS_SETERRNO'];
  60. begin
  61. Errno:=err;
  62. end;
  63. {$endif}
  64. { OS independant parts}
  65. {$I system.inc}
  66. { OS dependant parts }
  67. {$I errno.inc}
  68. {$I bunxtype.inc}
  69. {$I ossysc.inc}
  70. {$I osmain.inc}
  71. {$I text.inc}
  72. {$I heap.inc}
  73. {*****************************************************************************
  74. UnTyped File Handling
  75. *****************************************************************************}
  76. {$i file.inc}
  77. {*****************************************************************************
  78. Typed File Handling
  79. *****************************************************************************}
  80. {$i typefile.inc}
  81. procedure SysInitStdIO;
  82. begin
  83. OpenStdIO(Input,fmInput,StdInputHandle);
  84. OpenStdIO(Output,fmOutput,StdOutputHandle);
  85. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  86. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  87. end;
  88. Begin
  89. IsConsole := TRUE;
  90. IsLibrary := FALSE;
  91. StackBottom := Sptr - StackLength;
  92. { Set up signals handlers }
  93. InstallSignals;
  94. { Setup heap }
  95. InitHeap;
  96. SysInitExceptions;
  97. { Arguments }
  98. SetupCmdLine;
  99. { Setup stdin, stdout and stderr }
  100. SysInitStdIO;
  101. { Reset IO Error }
  102. InOutRes:=0;
  103. {$ifdef HASVARIANT}
  104. initvariantmanager;
  105. {$endif HASVARIANT}
  106. End.
  107. {
  108. $Log$
  109. Revision 1.11 2003-12-30 12:26:21 marco
  110. * FPC_USE_LIBC
  111. Revision 1.10 2003/10/26 17:01:04 marco
  112. * moved sigprocmask to system
  113. Revision 1.9 2003/10/26 16:42:22 marco
  114. * texception4 fix merge
  115. Revision 1.8 2003/01/05 19:01:28 marco
  116. * FreeBSD compiles now with baseunix mods.
  117. Revision 1.7 2002/11/12 14:57:48 marco
  118. * Ugly hack to temporarily be able to use system.pp for Linux too
  119. Revision 1.6 2002/10/27 11:58:30 marco
  120. * Modifications from Saturday.
  121. Revision 1.5 2002/10/26 18:27:51 marco
  122. * First series POSIX calls commits. Including getcwd.
  123. Revision 1.4 2002/10/18 12:19:58 marco
  124. * Fixes to get the generic *BSD RTL compiling again + fixes for thread
  125. support. Still problems left in fexpand. (inoutres?) Therefore fixed
  126. sysposix not yet commited
  127. Revision 1.3 2002/10/13 09:25:39 florian
  128. + call to initvariantmanager inserted
  129. Revision 1.2 2002/09/07 16:01:17 peter
  130. * old logs removed and tabs fixed
  131. Revision 1.1 2002/08/19 12:29:11 marco
  132. * First working POSIX *BSD system unit.
  133. }