baseunix.pp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2001 by Carl Eric Codere development team
  4. Base Unix unit modelled after POSIX 2001.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. Unit BaseUnix;
  12. Interface
  13. uses UnixType;
  14. {$i aliasptp.inc}
  15. {$packrecords C}
  16. {$define oldreaddir} // Keep using readdir system call instead
  17. // of userland getdents stuff.
  18. {$define usedomain} // Allow uname with "domain" entry.
  19. // (which is a GNU extension)
  20. {$define posixworkaround} // Temporary ugly workaround for signal handler.
  21. // (mainly until baseunix migration is complete)
  22. {$ifndef FPC_USE_LIBC}
  23. {$define FPC_USE_SYSCALL}
  24. {$endif}
  25. {$i errno.inc} { Error numbers }
  26. {$i ostypes.inc}
  27. {$ifdef FPC_USE_LIBC}
  28. const clib = 'root';
  29. const netlib = 'net';
  30. {$i oscdeclh.inc}
  31. {$ELSE}
  32. {$i bunxh.inc} { Functions}
  33. {$ENDIF}
  34. function fpgeterrno:longint;
  35. procedure fpseterrno(err:longint);
  36. {$ifndef ver1_0}
  37. property errno : cint read fpgeterrno write fpseterrno;
  38. {$endif}
  39. {$i bunxovlh.inc}
  40. {$ifdef FPC_USE_LIBC}
  41. {$ifdef beos}
  42. function fpsettimeofday(tp:ptimeval;tzp:ptimezone):cint;
  43. Function fStatFS(Fd:Longint;Var Info:tstatfs):cint;
  44. Function fpFlock (var fd : text; mode : longint) : cint;
  45. Function fpFlock (var fd : File; mode : longint) : cint;
  46. Function fpFlock (fd, mode : longint) : cint;
  47. Function StatFS (Path:string;Var Info:tstatfs):cint;
  48. Function FpNanoSleep (req : ptimespec;rem : ptimespec):cint;
  49. {$endif}
  50. {$endif}
  51. { Fairly portable constants. I'm not going to waste time to duplicate and alias
  52. them anywhere}
  53. Const
  54. MAP_FAILED = pointer(-1); { mmap() has failed }
  55. MAP_SHARED = $1; { Share changes }
  56. MAP_PRIVATE = $2; { Changes are private }
  57. MAP_TYPE = $f; { Mask for type of mapping }
  58. MAP_FIXED = $10; { Interpret addr exactly }
  59. // MAP_ANON(YMOUS) is OS dependant but used in the RTL and in ostypes.inc
  60. // Under BSD without -YMOUS, so alias it:
  61. MAP_ANON = MAP_ANONYMOUS;
  62. PROT_READ = $1; { page can be read }
  63. PROT_WRITE = $2; { page can be written }
  64. PROT_EXEC = $4; { page can be executed }
  65. PROT_NONE = $0; { page can not be accessed }
  66. implementation
  67. {$i genfuncs.inc} // generic calls. (like getenv)
  68. {$I gensigset.inc} // general sigset funcs implementation.
  69. {$I genfdset.inc} // general fdset funcs.
  70. {$ifndef FPC_USE_LIBC}
  71. {$i syscallh.inc} // do_syscall declarations themselves
  72. {$i sysnr.inc} // syscall numbers.
  73. {$i bsyscall.inc} // cpu specific syscalls
  74. {$i bunxsysc.inc} // syscalls in system unit.
  75. // {$i settimeo.inc}
  76. {$endif}
  77. {$i settimeo.inc}
  78. {$i osmacro.inc} { macro implenenations }
  79. {$i bunxovl.inc} { redefs and overloads implementation }
  80. {$ifndef ver1_0}
  81. function fpgeterrno:longint; external name 'FPC_SYS_GETERRNO';
  82. procedure fpseterrno(err:longint); external name 'FPC_SYS_SETERRNO';
  83. {$else}
  84. // workaround for 1.0.10 bugs.
  85. function intgeterrno:longint; external name 'FPC_SYS_GETERRNO';
  86. procedure intseterrno(err:longint); external name 'FPC_SYS_SETERRNO';
  87. function fpgeterrno:longint;
  88. begin
  89. fpgeterrno:=intgeterrno;
  90. end;
  91. procedure fpseterrno(err:longint);
  92. begin
  93. intseterrno(err);
  94. end;
  95. {$endif}
  96. function fpsettimeofday(tp:ptimeval;tzp:ptimezone):cint;
  97. begin
  98. fpsettimeofday := settimeofday(tp, tzp);
  99. end;
  100. Function fStatFS(Fd:Longint;Var Info:tstatfs):cint;
  101. begin
  102. {$warning TODO BeOS fStatFS implementation}
  103. end;
  104. Function fpFlock (var fd : File; mode : longint) : cint;
  105. begin
  106. {$warning TODO BeOS fpFlock implementation}
  107. end;
  108. Function fpFlock (var fd : Text; mode : longint) : cint;
  109. begin
  110. {$warning TODO BeOS fpFlock implementation}
  111. end;
  112. Function fpFlock (fd, mode : longint) : cint;
  113. begin
  114. {$warning TODO BeOS fpFlock implementation}
  115. end;
  116. Function StatFS (Path:string;Var Info:tstatfs):cint;
  117. begin
  118. {$warning TODO BeOS StatFS implementation}
  119. end;
  120. Function FpNanoSleep (req : ptimespec;rem : ptimespec):cint;
  121. begin
  122. {$warning TODO BeOS FpNanoSleep implementation}
  123. end;
  124. end.