bunxmain.inc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. {
  2. $Id$
  3. Copyright (c) 2002 by Marco van de Voort.
  4. Implementation of the POSIX unit for *BSD. In practice only includes
  5. other files, or specifies libc bindings.
  6. The conditional uselibc can be used to switch from libc to syscall
  7. usage for basic primitives, but it is best to use unit POSIX if
  8. possible. Note that the system unit must also be compiled using uselibc.
  9. See the file COPYING.FPC, included in this distribution,
  10. for details about the copyright.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. ****************************************************************************
  15. }
  16. Uses Sysctl;
  17. {$I ostypes.inc}
  18. {$I bunxmacr.inc}
  19. {$ifdef uselibc}
  20. {$Linklib c}
  21. { var
  22. Errno : cint; external name 'errno';}
  23. function Fptime(var tloc:time_t): time_t; cdecl; external name 'time';
  24. function Fpopen(path: pchar; flags : cint; mode: mode_t):cint; cdecl; external name 'open';
  25. function Fpclose(fd : cint): cint; cdecl; external name 'close';
  26. function Fplseek(fd : cint; offset : off_t; whence : cint): off_t; cdecl; external name 'lseek';
  27. function Fpread(fd: cint; buf: pchar; nbytes : size_t): ssize_t; cdecl; external name 'read';
  28. function Fpwrite(fd: cint;buf:pchar; nbytes : size_t): ssize_t; cdecl; external name 'write';
  29. function Fpunlink(path: pchar): cint; cdecl; external name 'unlink';
  30. function Fprename(old : pchar; const newpath: pchar): cint; cdecl;external name 'rename';
  31. function Fpstat( path: pchar; var buf : stat): cint; cdecl; external name 'stat';
  32. function Fpchdir(path : pchar): cint; cdecl; external name 'chdir';
  33. function Fpmkdir(path : pchar; mode: mode_t):cint; cdecl; external name 'mkdir';
  34. function Fprmdir(path : pchar): cint; cdecl; external name 'rmdir';
  35. function Fpopendir(dirname : pchar): pdir; cdecl; external name 'opendir';
  36. function Fpreaddir(var dirp : dir) : pdirent;cdecl; external name 'readdir';
  37. function Fpclosedir(var dirp : dir): cint; cdecl; external name 'closedir';
  38. procedure Fpexit(status : cint); cdecl; external name '_exit';
  39. function Fpsigaction(sig: cint; var act : sigactionrec; var oact : sigactionrec): cint; cdecl; external name 'sigaction';
  40. function Fpftruncate(fd : cint; flength : off_t): cint; cdecl; external name 'ftruncate';
  41. function Fprename(old : pchar; newpath: pchar): cint; cdecl;external name 'rename';
  42. function Fpfstat(fd : cint; var sb : stat): cint; cdecl; external name 'fstat';
  43. function Fpfork : pid_t; cdecl; external name 'fork';
  44. function Fpexecve(path : pchar; argv : ppchar; envp: ppchar): cint; cdecl; external name 'execve';
  45. function Fpwaitpid(pid : pid_t; var stat_loc : cint; options: cint): pid_t; cdecl; external name 'waitpid';
  46. function Fpaccess(pathname : pchar; amode : cint): cint; cdecl; external name 'access';
  47. function Fpuname(var name: utsname): cint; cdecl; external name 'uname';
  48. function FpDup(fildes:cint):cint; cdecl; external name 'dup';
  49. function FpDup2(fildes:cint;fildes2:cint):cint; cdecl; external name 'dup2';
  50. {$else}
  51. // uses syscalls.
  52. function Fptime(var tloc:time_t): time_t; external name 'FPC_SYSC_TIME';
  53. function Fpopen(path: pchar; flags : cint; mode: mode_t):cint; external name 'FPC_SYSC_OPEN';
  54. function Fpclose(fd : cint): cint; external name 'FPC_SYSC_CLOSE';
  55. function Fplseek(fd : cint; offset : off_t; whence : cint): off_t; external name 'FPC_SYSC_LSEEK';
  56. function Fpread(fd: cint; buf: pchar; nbytes : size_t): ssize_t; external name 'FPC_SYSC_READ';
  57. function Fpwrite(fd: cint;buf:pchar; nbytes : size_t): ssize_t; external name 'FPC_SYSC_WRITE';
  58. function Fpunlink(path: pchar): cint; external name 'FPC_SYSC_UNLINK';
  59. function Fprename(old : pchar; newpath: pchar): cint; external name 'FPC_SYSC_RENAME';
  60. function Fpstat(path: pchar; var buf : stat):cint; external name 'FPC_SYSC_STAT';
  61. function Fpchdir(path : pchar): cint; external name 'FPC_SYSC_CHDIR';
  62. function Fpmkdir(path : pchar; mode: mode_t):cint; external name 'FPC_SYSC_MKDIR';
  63. function Fprmdir(path : pchar): cint; external name 'FPC_SYSC_RMDIR';
  64. function Fpopendir(dirname : pchar): pdir; external name 'FPC_SYSC_OPENDIR';
  65. function Fpclosedir(var dirp : dir): cint; external name 'FPC_SYSC_CLOSEDIR';
  66. function Fpreaddir(var dirp : dir) : pdirent; external name 'FPC_SYSC_READDIR';
  67. procedure Fpexit(status : cint); external name 'FPC_SYSC_EXIT';
  68. function Fpsigaction(sig: cint; var act : sigactionrec; var oact : sigactionrec): cint; external name 'FPC_SYSC_SIGACTION';
  69. function Fpftruncate(fd : cint; flength : off_t): cint; external name 'FPC_SYSC_FTRUNCATE';
  70. function Fpfstat(fd : cint; var sb : stat): cint; external name 'FPC_SYSC_FSTAT';
  71. function Fpfork : pid_t; external name 'FPC_SYSC_FORK';
  72. // function Fpexecve(path : pchar; argv : ppchar;envp: ppchar): cint; external name 'FPC_SYSC_EXECVE';
  73. function Fpwaitpid(pid : pid_t; var stat_loc : cint; options: cint): pid_t; external name 'FPC_SYSC_WAITPID';
  74. function Fpaccess(pathname : pchar; amode : cint): cint;external name 'FPC_SYSC_ACCESS';
  75. function FpDup(fildes:cint):cint; external name 'FPC_SYSC_DUP';
  76. function FpDup2(fildes:cint;fildes2:cint):cint; external name 'FPC_SYSC_DUP2';
  77. function geterrno:cint; external name 'FPC_SYS_GETERRNO';
  78. procedure seterrno (i:cint); external name 'FPC_SYS_SETERRNO';
  79. {$endif}
  80. {$I bunxfunc.inc}
  81. {
  82. $Log$
  83. Revision 1.1 2003-01-05 19:01:28 marco
  84. * FreeBSD compiles now with baseunix mods.
  85. Revision 1.8 2002/10/27 17:21:29 marco
  86. * Only "difficult" functions + execvp + termios + rewinddir left to do
  87. Revision 1.7 2002/10/27 11:58:30 marco
  88. * Modifications from Saturday.
  89. Revision 1.6 2002/10/26 18:27:51 marco
  90. * First series POSIX calls commits. Including getcwd.
  91. Revision 1.5 2002/09/07 16:01:17 peter
  92. * old logs removed and tabs fixed
  93. Revision 1.4 2002/08/21 07:03:16 marco
  94. * Fixes from Tuesday.
  95. Revision 1.3 2002/08/19 12:29:11 marco
  96. * First working POSIX *BSD system unit.
  97. }