baseunix.pp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 fpFlock (var fd : text; mode : longint) : cint;
  44. Function fpFlock (var fd : File; mode : longint) : cint;
  45. Function fpFlock (fd, mode : longint) : cint;
  46. Function FpNanoSleep (req : ptimespec;rem : ptimespec):cint;
  47. {$endif}
  48. {$endif}
  49. { Fairly portable constants. I'm not going to waste time to duplicate and alias
  50. them anywhere}
  51. Const
  52. MAP_FAILED = pointer(-1); { mmap() has failed }
  53. MAP_SHARED = $1; { Share changes }
  54. MAP_PRIVATE = $2; { Changes are private }
  55. MAP_TYPE = $f; { Mask for type of mapping }
  56. MAP_FIXED = $10; { Interpret addr exactly }
  57. // MAP_ANON(YMOUS) is OS dependant but used in the RTL and in ostypes.inc
  58. // Under BSD without -YMOUS, so alias it:
  59. MAP_ANON = MAP_ANONYMOUS;
  60. PROT_READ = $1; { page can be read }
  61. PROT_WRITE = $2; { page can be written }
  62. PROT_EXEC = $4; { page can be executed }
  63. PROT_NONE = $0; { page can not be accessed }
  64. implementation
  65. {$i genfuncs.inc} // generic calls. (like getenv)
  66. {$I gensigset.inc} // general sigset funcs implementation.
  67. {$I genfdset.inc} // general fdset funcs.
  68. {$ifndef FPC_USE_LIBC}
  69. {$i syscallh.inc} // do_syscall declarations themselves
  70. {$i sysnr.inc} // syscall numbers.
  71. {$i bsyscall.inc} // cpu specific syscalls
  72. {$i bunxsysc.inc} // syscalls in system unit.
  73. // {$i settimeo.inc}
  74. {$endif}
  75. {$i settimeo.inc}
  76. {$i osmacro.inc} { macro implenenations }
  77. {$i bunxovl.inc} { redefs and overloads implementation }
  78. {$ifndef ver1_0}
  79. function fpgeterrno:longint; external name 'FPC_SYS_GETERRNO';
  80. procedure fpseterrno(err:longint); external name 'FPC_SYS_SETERRNO';
  81. {$else}
  82. // workaround for 1.0.10 bugs.
  83. function intgeterrno:longint; external name 'FPC_SYS_GETERRNO';
  84. procedure intseterrno(err:longint); external name 'FPC_SYS_SETERRNO';
  85. function fpgeterrno:longint;
  86. begin
  87. fpgeterrno:=intgeterrno;
  88. end;
  89. procedure fpseterrno(err:longint);
  90. begin
  91. intseterrno(err);
  92. end;
  93. {$endif}
  94. function fpsettimeofday(tp:ptimeval;tzp:ptimezone):cint;
  95. begin
  96. fpsettimeofday := settimeofday(tp, tzp);
  97. end;
  98. Function fpFlock (var fd : File; mode : longint) : cint;
  99. begin
  100. {$warning TODO BeOS fpFlock implementation}
  101. end;
  102. Function fpFlock (var fd : Text; mode : longint) : cint;
  103. begin
  104. {$warning TODO BeOS fpFlock implementation}
  105. end;
  106. Function fpFlock (fd, mode : longint) : cint;
  107. begin
  108. {$warning TODO BeOS fpFlock implementation}
  109. end;
  110. Function FpNanoSleep (req : ptimespec;rem : ptimespec):cint;
  111. begin
  112. {$warning TODO BeOS FpNanoSleep implementation}
  113. end;
  114. end.