2
0

baseunix.pp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. {$IFNDEF FPC_DOTTEDUNITS}
  12. Unit BaseUnix;
  13. {$ENDIF FPC_DOTTEDUNITS}
  14. Interface
  15. {$modeswitch out}
  16. {$inline on}
  17. {$IFDEF FPC_DOTTEDUNITS}
  18. Uses UnixApi.Types;
  19. {$ELSE FPC_DOTTEDUNITS}
  20. Uses UnixType;
  21. {$ENDIF FPC_DOTTEDUNITS}
  22. {$i osdefs.inc} { Compile time defines }
  23. {$i aliasptp.inc}
  24. {$packrecords C}
  25. {$i errno.inc} { Error numbers }
  26. {$i ostypes.inc}
  27. const
  28. clib = 'root';
  29. netlib = 'network';
  30. {$i oscdeclh.inc}
  31. function fpgeterrno:longint; external name 'FPC_SYS_GETERRNO';
  32. procedure fpseterrno(err:longint); external name 'FPC_SYS_SETERRNO';
  33. property errno : cint read fpgeterrno write fpseterrno;
  34. {$i bunxovlh.inc}
  35. function fpsettimeofday(tp:ptimeval;tzp:ptimezone):cint;
  36. {$i genfunch.inc}
  37. { Fairly portable constants. I'm not going to waste time to duplicate and alias
  38. them anywhere}
  39. Const
  40. MAP_FAILED = pointer(-1); { mmap() has failed }
  41. MAP_SHARED = $1; { Share changes }
  42. MAP_PRIVATE = $2; { Changes are private }
  43. MAP_TYPE = $f; { Mask for type of mapping }
  44. MAP_FIXED = $10; { Interpret addr exactly }
  45. // MAP_ANON(YMOUS) is OS dependant but used in the RTL and in ostypes.inc
  46. // Under BSD without -YMOUS, so alias it:
  47. MAP_ANON = MAP_ANONYMOUS;
  48. PROT_READ = $1; { page can be read }
  49. PROT_WRITE = $2; { page can be written }
  50. PROT_EXEC = $4; { page can be executed }
  51. PROT_NONE = $0; { page can not be accessed }
  52. implementation
  53. {$ifdef hassysctl}
  54. Uses Sysctl;
  55. {$endif}
  56. {$i genfuncs.inc} // generic calls. (like getenv)
  57. {$I gensigset.inc} // general sigset funcs implementation.
  58. {$I genfdset.inc} // general fdset funcs.
  59. {$i oscdecl.inc} // implementation of wrappers in oscdeclh.inc
  60. {$i osmacro.inc} { macro implenenations }
  61. {$i bunxovl.inc} { redefs and overloads implementation }
  62. function stime(t: ptime_t): cint; cdecl; external clib name 'stime';
  63. function fpsettimeofday(tp:ptimeval;tzp:ptimezone):cint;
  64. begin
  65. fpsettimeofday:=stime(@tp^.tv_sec);
  66. end;
  67. end.