gensigset.inc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 sys_sigaddset(var _set : sigset_t;signo:cint): cint;
  14. Begin
  15. if (signo<=0) or (signo > SIG_MAXSIG) Then
  16. Begin
  17. seterrno(sys_EINVAL);
  18. exit(-1);
  19. End;
  20. _set[(signo-1) shr ln2bitsinword]:=_set[(signo-1) shr ln2bitsinword] OR (1 shl ((signo-1) and ln2bitmask));
  21. sys_sigaddset:=0;
  22. End;
  23. function sys_sigdelset(var _set : sigset_t;signo:cint): cint;
  24. Begin
  25. if (signo<=0) or (signo > SIG_MAXSIG) Then
  26. Begin
  27. seterrno(sys_EINVAL);
  28. exit(-1);
  29. End;
  30. _set[(signo-1) shr ln2bitsinword]:=_set[(signo-1) shr ln2bitsinword] AND NOT (1 shl ((signo-1) and ln2bitmask));
  31. sys_sigdelset:=0;
  32. End;
  33. function sys_sigemptyset(var _set : sigset_t):cint;
  34. var i :longint;
  35. Begin
  36. for i:=0 to wordsinsigset-1 DO _set[i]:=0;
  37. sys_sigemptyset:=0;
  38. End;
  39. function sys_sigfillset(var _set : sigset_t):cint;
  40. var i :longint;
  41. Begin
  42. for i:=0 to wordsinsigset DO _set[i]:=NOT 0;
  43. sys_sigfillset:=0;
  44. End;
  45. function sys_sigismember(const _set : sigset_t;signo:cint): cint;
  46. Begin
  47. if (signo<=0) or (signo > SIG_MAXSIG) Then
  48. Begin
  49. seterrno(sys_EINVAL);
  50. exit(-1);
  51. End;
  52. if ((_set[(signo-1) shr ln2bitsinword]) and (1 shl ((signo-1) and ln2bitmask)))>0 Then
  53. sys_sigismember:=1
  54. else
  55. sys_sigismember:=0;
  56. End;
  57. {
  58. $Log$
  59. Revision 1.1 2002-11-14 12:20:30 marco
  60. * initial version, taken from bsdfunc.inc, since both linux and bsd use it
  61. }