genfdset.inc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 shr ln2bitsinword]:=nset[(fdno) shr ln2bitsinword] OR (1 shl ((fdno) 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) shr ln2bitsinword]:=nset[(fdno) shr ln2bitsinword] AND Cardinal(NOT (1 shl ((fdno) 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-1 DO nset[i]:=Cardinal(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) shr ln2bitsinword]) and (1 shl ((fdno) and ln2bitmask)))>0 Then
  44. fpFD_ISSET:=1
  45. else
  46. fpFD_ISSET:=0;
  47. End;
  48. {
  49. $Log$
  50. Revision 1.4 2003-10-23 12:06:14 marco
  51. * fd's now walk from 0..maxset again. IDE/unit kbd works again.
  52. Revision 1.3 2003/09/22 19:43:22 peter
  53. * Fix range check error for Not 0
  54. * Fix loop in fdfillfdset
  55. Revision 1.2 2003/09/16 16:13:56 marco
  56. * fdset functions renamed to fp<posix name>
  57. Revision 1.1 2003/09/14 20:16:48 marco
  58. * new files unixreform
  59. Revision 1.3 2003/06/01 16:28:41 marco
  60. * Enhancements to make the compiler baseunix using.
  61. Revision 1.2 2002/12/18 16:50:39 marco
  62. * Unix RTL generic parts. Linux working, *BSD will follow shortly
  63. Revision 1.1 2002/11/14 12:20:30 marco
  64. * initial version, taken from bsdfunc.inc, since both linux and bsd use it
  65. }