unixsysc.inc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Michael Van Canneyt,
  5. member of the Free Pascal development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY;without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. Function fsync (fd : cint) : cint;
  13. begin
  14. fsync := do_SysCall(syscall_nr_fsync, fd);
  15. end;
  16. Function Flock (fd,mode : cint) : cint;
  17. begin
  18. flock:=do_Syscall(Syscall_nr_flock,fd,mode);
  19. end;
  20. {
  21. Function StatFS(Path:Pathstr;Var Info:tstatfs):cint;
  22. {
  23. Get all information on a fileSystem, and return it in Info.
  24. Path is the name of a file/directory on the fileSystem you wish to
  25. investigate.
  26. }
  27. begin
  28. path:=path+#0;
  29. StatFS:=(do_SysCall(SysCall_nr_statfs,longint(@path[1]),longint(@Info)));
  30. end;
  31. }
  32. Function fStatFS(Fd:cint;Var Info:tstatfs):cint;
  33. {
  34. Get all information on a fileSystem, and return it in Info.
  35. Fd is the file descriptor of a file/directory on the fileSystem
  36. you wish to investigate.
  37. }
  38. begin
  39. fStatFS:=(do_SysCall(SysCall_nr_fstatfs,fd,longint(@info)));
  40. end;
  41. Function AssignPipe(var pipe_in,pipe_out:cint):cint; [public, alias : 'FPC_SYSC_ASSIGNPIPE'];
  42. {
  43. Sets up a pair of file variables, which act as a pipe. The first one can
  44. be read from, the second one can be written to.
  45. If the operation was unsuccesful, linuxerror is set.
  46. }
  47. var
  48. pip : tpipe;
  49. begin
  50. assignPipe:=do_SysCall(SysCall_nr_pipe,longint(@pip));
  51. pipe_in:=pip[1];
  52. pipe_out:=pip[2];
  53. end;
  54. Function PClose(Var F:text) :cint;
  55. var
  56. pl : ^cint;
  57. res : cint;
  58. begin
  59. do_SysCall (syscall_nr_close,Textrec(F).Handle);
  60. { closed our side, Now wait for the other - this appears to be needed ?? }
  61. pl:=@(textrec(f).userdata[2]);
  62. fpwaitpid(pl^,@res,0);
  63. pclose:=res shr 8;
  64. end;
  65. Function PClose(Var F:file) : cint;
  66. var
  67. pl : ^cint;
  68. res : cint;
  69. begin
  70. do_SysCall (Syscall_nr_close,filerec(F).Handle);
  71. { closed our side, Now wait for the other - this appears to be needed ?? }
  72. pl:=@(filerec(f).userdata[2]);
  73. fpwaitpid(pl^,@res,0);
  74. pclose:=res shr 8;
  75. end;
  76. {--------------------------------
  77. Port IO functions
  78. --------------------------------}
  79. {$ifdef cpui386}
  80. Function IOperm (From,Num : cuint; Value : cint) : boolean;
  81. {
  82. Set permissions on NUM ports starting with port FROM to VALUE
  83. this works ONLY as root.
  84. }
  85. begin
  86. IOPerm:=do_Syscall(Syscall_nr_ioperm,from,num,value)=0;
  87. end;
  88. Function IoPL(Level : cint) : Boolean;
  89. begin
  90. IOPL:=do_Syscall(Syscall_nr_iopl,level)=0;
  91. end;
  92. {$endif cpui386}
  93. {
  94. $Log$
  95. Revision 1.22 2003-12-30 12:36:56 marco
  96. * FPC_USE_LIBC
  97. Revision 1.21 2003/11/19 11:46:55 marco
  98. * changes due to the previous *BSD changes. Mainly moving constants from
  99. unix to systypes.inc (which acts as unxtypes.inc)
  100. Revision 1.20 2003/11/17 10:21:47 marco
  101. * small fixes for changing unit unix again
  102. Revision 1.19 2003/11/17 10:05:51 marco
  103. * threads for FreeBSD. Not working tho
  104. Revision 1.18 2003/11/13 17:40:12 marco
  105. * small fixes
  106. Revision 1.17 2003/11/13 13:36:23 marco
  107. * Linuxerror removed
  108. Revision 1.16 2003/11/09 13:48:55 marco
  109. * small fix
  110. Revision 1.15 2003/10/30 16:42:25 marco
  111. * Killing off old syscall convention anywhere except for oldlinux
  112. Revision 1.14 2003/10/17 22:11:28 olle
  113. * changed i386 to cpui386
  114. Revision 1.13 2003/09/20 12:45:34 marco
  115. * Small fix. Cycle works
  116. Revision 1.12 2003/09/16 21:46:27 marco
  117. * small fixes, checking things on linux
  118. Revision 1.11 2003/09/15 21:07:32 marco
  119. * second round of linux fixes. oldlinux now works
  120. Revision 1.10 2003/09/14 20:15:01 marco
  121. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  122. Revision 1.9 2003/07/08 21:23:24 peter
  123. * sparc fixes
  124. Revision 1.8 2002/12/18 16:43:26 marco
  125. * new unix rtl, linux part.....
  126. Revision 1.7 2002/09/07 16:01:20 peter
  127. * old logs removed and tabs fixed
  128. Revision 1.6 2002/03/05 20:04:25 michael
  129. + Patch from Sebastian for FCNTL call
  130. }