genfdset.inc 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. (c) 2002 by Marco van de Voort
  5. members of the Free Pascal development team.
  6. Generic POSIX signal functions draft. Based on a few constants.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY;without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. function fpFD_SET(fdno:cint;var nset : TFDSet): cint;
  14. Begin
  15. if (fdno<=0) or (fdno > FD_MAXFDSET) Then
  16. exit(-1);
  17. nset[(fdno-1) shr ln2bitsinword]:=nset[(fdno-1) shr ln2bitsinword] OR (1 shl ((fdno-1) and ln2bitmask));
  18. fpFD_SET:=0;
  19. End;
  20. function fpFD_CLR(fdno:cint;var nset : TFDSet): cint;
  21. Begin
  22. if (fdno<=0) or (fdno > FD_MAXFDSET) Then
  23. exit(-1);
  24. nset[(fdno-1) shr ln2bitsinword]:=nset[(fdno-1) shr ln2bitsinword] AND NOT (1 shl ((fdno-1) and ln2bitmask));
  25. fpFD_CLR:=0;
  26. End;
  27. function fpFD_ZERO(var nset : TFDSet):cint;
  28. var i :longint;
  29. Begin
  30. for i:=0 to wordsinsigset-1 DO nset[i]:=0;
  31. fpFD_ZERO:=0;
  32. End;
  33. function fpfdfillset(var nset : TFDSet):cint;
  34. var i :longint;
  35. Begin
  36. for i:=0 to wordsinsigset DO nset[i]:=NOT 0;
  37. fpfdfillset:=0;
  38. End;
  39. function fpFD_ISSET(fdno:cint;const nset : TFDSet): cint;
  40. Begin
  41. if (fdno<=0) or (fdno > FD_MAXFDSET) Then
  42. exit(-1);
  43. if ((nset[(fdno-1) shr ln2bitsinword]) and (1 shl ((fdno-1) and ln2bitmask)))>0 Then
  44. fpFD_ISSET:=1
  45. else
  46. fpFD_ISSET:=0;
  47. End;
  48. {
  49. $Log$
  50. Revision 1.2 2003-09-16 16:13:56 marco
  51. * fdset functions renamed to fp<posix name>
  52. Revision 1.1 2003/09/14 20:16:48 marco
  53. * new files unixreform
  54. Revision 1.3 2003/06/01 16:28:41 marco
  55. * Enhancements to make the compiler baseunix using.
  56. Revision 1.2 2002/12/18 16:50:39 marco
  57. * Unix RTL generic parts. Linux working, *BSD will follow shortly
  58. Revision 1.1 2002/11/14 12:20:30 marco
  59. * initial version, taken from bsdfunc.inc, since both linux and bsd use it
  60. }