genfdset.inc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {
  2. This file is part of the Free Pascal run time library.
  3. (c) 2002 by Marco van de Voort
  4. members of the Free Pascal development team.
  5. Generic POSIX signal functions draft. Based on a few constants.
  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 fpFD_SET(fdno:cint;var nset : TFDSet): cint;
  13. Begin
  14. if (fdno<0) or (fdno > FD_MAXFDSET) Then
  15. exit(-1);
  16. nset[fdno shr ln2bitsinword]:=nset[(fdno) shr ln2bitsinword] OR (culong(1) shl ((fdno) and ln2bitmask));
  17. fpFD_SET:=0;
  18. End;
  19. function fpFD_CLR(fdno:cint;var nset : TFDSet): cint;
  20. Begin
  21. if (fdno<0) or (fdno > FD_MAXFDSET) Then
  22. exit(-1);
  23. nset[(fdno) shr ln2bitsinword]:=nset[(fdno) shr ln2bitsinword] AND Cardinal(NOT (culong(1) shl ((fdno) and ln2bitmask)));
  24. fpFD_CLR:=0;
  25. End;
  26. function fpFD_ZERO(var nset : TFDSet):cint;
  27. var i :longint;
  28. Begin
  29. for i:=0 to wordsinfdset-1 DO nset[i]:=0;
  30. fpFD_ZERO:=0;
  31. End;
  32. function fpfdfillset(var nset : TFDSet):cint;
  33. var i :longint;
  34. Begin
  35. for i:=0 to wordsinfdset-1 DO nset[i]:=Cardinal(NOT 0);
  36. fpfdfillset:=0;
  37. End;
  38. function fpFD_ISSET(fdno:cint;const nset : TFDSet): cint;
  39. Begin
  40. if (fdno<0) or (fdno > FD_MAXFDSET) Then
  41. exit(-1);
  42. if ((nset[fdno shr ln2bitsinword]) and (culong(1) shl ((fdno) and ln2bitmask)))>0 Then
  43. fpFD_ISSET:=1
  44. else
  45. fpFD_ISSET:=0;
  46. End;