gensigset.inc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 fpsigaddset(var nset : tsigset;signo:cint): cint;
  13. Begin
  14. if (signo<=0) or (signo > SIG_MAXSIG) Then
  15. Begin
  16. fpseterrno(ESysEINVAL);
  17. exit(-1);
  18. End;
  19. nset[(signo-1) shr ln2bitsinword]:=nset[(signo-1) shr ln2bitsinword] OR (1 shl ((signo-1) and ln2bitmask));
  20. fpsigaddset:=0;
  21. End;
  22. function fpsigdelset(var nset : tsigset;signo:cint): cint;
  23. Begin
  24. if (signo<=0) or (signo > SIG_MAXSIG) Then
  25. Begin
  26. fpseterrno(ESysEINVAL);
  27. exit(-1);
  28. End;
  29. nset[(signo-1) shr ln2bitsinword]:=nset[(signo-1) shr ln2bitsinword] AND NOT (1 shl ((signo-1) and ln2bitmask));
  30. fpsigdelset:=0;
  31. End;
  32. function fpsigemptyset(var nset : tsigset):cint;
  33. var i :longint;
  34. Begin
  35. for i:=0 to wordsinsigset-1 DO nset[i]:=0;
  36. fpsigemptyset:=0;
  37. End;
  38. function fpsigfillset(var nset : tsigset):cint;
  39. var i :longint;
  40. Begin
  41. for i:=0 to wordsinsigset-1 DO nset[i]:=high(nset[i]);
  42. fpsigfillset:=0;
  43. End;
  44. function fpsigismember(const nset : tsigset;signo:cint): cint;
  45. Begin
  46. if (signo<=0) or (signo > SIG_MAXSIG) Then
  47. Begin
  48. fpseterrno(ESysEINVAL);
  49. exit(-1);
  50. End;
  51. if ((nset[(signo-1) shr ln2bitsinword]) and (1 shl ((signo-1) and ln2bitmask)))>0 Then
  52. fpsigismember:=1
  53. else
  54. fpsigismember:=0;
  55. End;