unixsysc.inc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 fdFlush (fd : cint) : cint;
  13. begin
  14. fdFlush := 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. Function StatFS(Path:Pathstr;Var Info:tstatfs):cint;
  21. {
  22. Get all information on a fileSystem, and return it in Info.
  23. Path is the name of a file/directory on the fileSystem you wish to
  24. investigate.
  25. }
  26. begin
  27. path:=path+#0;
  28. StatFS:=(do_SysCall(SysCall_nr_statfs,longint(@path[1]),longint(@Info));
  29. end;
  30. Function fStatFS(Fd:cint;Var Info:tstatfs):cint;
  31. {
  32. Get all information on a fileSystem, and return it in Info.
  33. Fd is the file descriptor of a file/directory on the fileSystem
  34. you wish to investigate.
  35. }
  36. begin
  37. fStatFS:=(do_SysCall(SysCall_nr_fstatfs,fd,longint(@info)));
  38. end;
  39. Function AssignPipe(var pipe_in,pipe_out:cint):cint; [public, alias : 'FPC_SYSC_ASSIGNPIPE'];
  40. {
  41. Sets up a pair of file variables, which act as a pipe. The first one can
  42. be read from, the second one can be written to.
  43. If the operation was unsuccesful, linuxerror is set.
  44. }
  45. var
  46. pip : tpipe;
  47. begin
  48. assignPipe:=do_SysCall(SysCall_nr_pipe,longint(@pip));
  49. pipe_in:=pip[1];
  50. pipe_out:=pip[2];
  51. end;
  52. Function PClose(Var F:text) :cint;
  53. var
  54. pl : ^cint;
  55. res : cint;
  56. begin
  57. do_SysCall (syscall_nr_close,Textrec(F).Handle);
  58. { closed our side, Now wait for the other - this appears to be needed ?? }
  59. pl:=@(textrec(f).userdata[2]);
  60. fpwaitpid(pl^,@res,0);
  61. pclose:=res shr 8;
  62. end;
  63. Function PClose(Var F:file) : cint;
  64. var
  65. pl : ^cint;
  66. res : cint;
  67. begin
  68. do_SysCall (Syscall_nr_close,filerec(F).Handle);
  69. { closed our side, Now wait for the other - this appears to be needed ?? }
  70. pl:=@(filerec(f).userdata[2]);
  71. fpwaitpid(pl^,@res,0);
  72. pclose:=res shr 8;
  73. end;
  74. {--------------------------------
  75. Port IO functions
  76. --------------------------------}
  77. {$ifdef cpui386}
  78. Function IOperm (From,Num : cuint; Value : cint) : boolean;
  79. {
  80. Set permissions on NUM ports starting with port FROM to VALUE
  81. this works ONLY as root.
  82. }
  83. begin
  84. IOPerm:=do_Syscall(Syscall_nr_ioperm,from,num,value)=0;
  85. end;
  86. Function IoPL(Level : cint) : Boolean;
  87. begin
  88. IOPL:=do_Syscall(Syscall_nr_iopl,level)=0;
  89. end;
  90. {$endif cpui386}
  91. {
  92. $Log$
  93. Revision 1.19 2003-11-17 10:05:51 marco
  94. * threads for FreeBSD. Not working tho
  95. Revision 1.18 2003/11/13 17:40:12 marco
  96. * small fixes
  97. Revision 1.17 2003/11/13 13:36:23 marco
  98. * Linuxerror removed
  99. Revision 1.16 2003/11/09 13:48:55 marco
  100. * small fix
  101. Revision 1.15 2003/10/30 16:42:25 marco
  102. * Killing off old syscall convention anywhere except for oldlinux
  103. Revision 1.14 2003/10/17 22:11:28 olle
  104. * changed i386 to cpui386
  105. Revision 1.13 2003/09/20 12:45:34 marco
  106. * Small fix. Cycle works
  107. Revision 1.12 2003/09/16 21:46:27 marco
  108. * small fixes, checking things on linux
  109. Revision 1.11 2003/09/15 21:07:32 marco
  110. * second round of linux fixes. oldlinux now works
  111. Revision 1.10 2003/09/14 20:15:01 marco
  112. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  113. Revision 1.9 2003/07/08 21:23:24 peter
  114. * sparc fixes
  115. Revision 1.8 2002/12/18 16:43:26 marco
  116. * new unix rtl, linux part.....
  117. Revision 1.7 2002/09/07 16:01:20 peter
  118. * old logs removed and tabs fixed
  119. Revision 1.6 2002/03/05 20:04:25 michael
  120. + Patch from Sebastian for FCNTL call
  121. }