unixfunc.inc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 AssignPipe(var pipe_in,pipe_out:cint):cint; [public, alias : 'FPC_SYSC_ASSIGNPIPE'];
  13. {
  14. Sets up a pair of file variables, which act as a pipe. The first one can
  15. be read from, the second one can be written to.
  16. If the operation was unsuccesful, linuxerror is set.
  17. }
  18. var
  19. pip : tpipe;
  20. begin
  21. {$ifdef FPC_USE_LIBC}
  22. assignpipe:=pipe(pip);
  23. {$else}
  24. assignPipe:=do_SysCall(SysCall_nr_pipe,TSysParam(@pip));
  25. {$endif}
  26. pipe_in:=pip[0];
  27. pipe_out:=pip[1];
  28. end;
  29. Function PClose(Var F:text) :cint;
  30. var
  31. pl : ^cint;
  32. res : cint;
  33. begin
  34. fpclose(Textrec(F).Handle);
  35. { closed our side, Now wait for the other - this appears to be needed ?? }
  36. pl:=@(textrec(f).userdata[2]);
  37. fpwaitpid(pl^,@res,0);
  38. pclose:=res shr 8;
  39. end;
  40. Function PClose(Var F:file) : cint;
  41. var
  42. pl : ^cint;
  43. res : cint;
  44. begin
  45. fpclose(filerec(F).Handle);
  46. { closed our side, Now wait for the other - this appears to be needed ?? }
  47. pl:=@(filerec(f).userdata[2]);
  48. fpwaitpid(pl^,@res,0);
  49. pclose:=res shr 8;
  50. end;
  51. {
  52. $Log$
  53. Revision 1.1 2005-02-13 20:01:38 peter
  54. * include file cleanup
  55. Revision 1.27 2004/04/28 20:48:20 peter
  56. * ordinal-pointer conversions fixed
  57. Revision 1.26 2004/04/23 19:16:24 marco
  58. * flock -> fpflock because of conflicting structure name
  59. Revision 1.25 2004/01/02 22:46:29 marco
  60. * fix from Marc W.
  61. Revision 1.24 2003/12/31 20:23:31 marco
  62. * small fixes for exporting statfs(pchar,..)
  63. Revision 1.23 2003/12/30 15:43:20 marco
  64. * linux now compiles with FPC_USE_LIBC
  65. Revision 1.22 2003/12/30 12:36:56 marco
  66. * FPC_USE_LIBC
  67. Revision 1.21 2003/11/19 11:46:55 marco
  68. * changes due to the previous *BSD changes. Mainly moving constants from
  69. unix to systypes.inc (which acts as unxtypes.inc)
  70. Revision 1.20 2003/11/17 10:21:47 marco
  71. * small fixes for changing unit unix again
  72. Revision 1.19 2003/11/17 10:05:51 marco
  73. * threads for FreeBSD. Not working tho
  74. Revision 1.18 2003/11/13 17:40:12 marco
  75. * small fixes
  76. Revision 1.17 2003/11/13 13:36:23 marco
  77. * Linuxerror removed
  78. Revision 1.16 2003/11/09 13:48:55 marco
  79. * small fix
  80. Revision 1.15 2003/10/30 16:42:25 marco
  81. * Killing off old syscall convention anywhere except for oldlinux
  82. Revision 1.14 2003/10/17 22:11:28 olle
  83. * changed i386 to cpui386
  84. Revision 1.13 2003/09/20 12:45:34 marco
  85. * Small fix. Cycle works
  86. Revision 1.12 2003/09/16 21:46:27 marco
  87. * small fixes, checking things on linux
  88. Revision 1.11 2003/09/15 21:07:32 marco
  89. * second round of linux fixes. oldlinux now works
  90. Revision 1.10 2003/09/14 20:15:01 marco
  91. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  92. Revision 1.9 2003/07/08 21:23:24 peter
  93. * sparc fixes
  94. Revision 1.8 2002/12/18 16:43:26 marco
  95. * new unix rtl, linux part.....
  96. Revision 1.7 2002/09/07 16:01:20 peter
  97. * old logs removed and tabs fixed
  98. Revision 1.6 2002/03/05 20:04:25 michael
  99. + Patch from Sebastian for FCNTL call
  100. }