event.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Declarations for event handling.
  2. This file is part of khipu.
  3. khipu is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  13. #ifndef __KP_EVENT__
  14. #define __KP_EVENT__ 1
  15. #include <csignal>
  16. #include "defs.hpp"
  17. #include "initop.hpp"
  18. KP_DECLS_BEGIN
  19. struct interpreter;
  20. const int KP_NSIG =
  21. #ifdef NSIG
  22. NSIG;
  23. #elif defined (_NSIG)
  24. _NSIG;
  25. #elif defined (SIGMAX)
  26. SIGMAX + 1;
  27. #elif defined (SIG_MAX)
  28. SIG_MAX + 1;
  29. #elif defined (_SIGMAX)
  30. _SIGMAX + 1;
  31. #else
  32. 8 * sizeof (sigset_t) + 1;
  33. #endif
  34. const int THREXIT_EV = KP_NSIG + 1;
  35. const int PROCEXIT_EV = KP_NSIG + 2;
  36. const int GCREQ_EV = KP_NSIG + 3;
  37. // All signals + the three above.
  38. const int NPENDEV = KP_NSIG + 3;
  39. // Install the event handler FCT for event EV.
  40. object add_evhandler (interpreter *interp, unsigned int ev, object fct);
  41. // Get the event handler for event EV.
  42. object get_evhandler (interpreter *interp, unsigned int ev);
  43. // Init OP for the event subsystem.
  44. KP_EXPORT init_op init_event;
  45. KP_DECLS_END
  46. #endif