event.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Part of Scheme 48 1.9. See file COPYING for notices and license.
  3. *
  4. * Authors: Richard Kelsey, Jonathan Rees, Mike Sperber
  5. */
  6. /* must be synchronized with EVENTS enumeration in ps-channel.scm and s48-channel.scm */
  7. enum event_enum { KEYBOARD_INTERRUPT_EVENT, IO_COMPLETION_EVENT, IO_ERROR_EVENT,
  8. ALARM_EVENT, OS_SIGNAL_EVENT, ERROR_EVENT, EXTERNAL_EVENT, NO_EVENT };
  9. S48_EXTERN psbool s48_add_pending_fd(int fd, psbool is_input);
  10. S48_EXTERN psbool s48_remove_fd(int fd);
  11. S48_EXTERN long s48_schedule_alarm_interrupt(long delta);
  12. S48_EXTERN void s48_start_alarm_interrupts(void);
  13. S48_EXTERN void s48_stop_alarm_interrupts(void);
  14. #ifndef _WIN32
  15. S48_EXTERN void s48_add_os_signal(long);
  16. S48_EXTERN void s48_when_keyboard_interrupt(int ign);
  17. S48_EXTERN void s48_when_alarm_interrupt(int ign);
  18. S48_EXTERN void s48_when_external_event_interrupt(int ign);
  19. #endif
  20. extern long s48_run_time(long *mseconds);
  21. extern long s48_real_time(long *mseconds);
  22. extern int s48_wait_for_event(long max_wait, psbool is_minutes);
  23. extern int s48_get_next_event(long *ready_fd, long *status);
  24. extern long s48_dequeue_external_event(char *pendingp);
  25. /* these are here only for the CHEAP_TIME() macro */
  26. #define TICKS_PER_SECOND 1000 /* clock resolution */
  27. #define POLLS_PER_SECOND 20 /* how often we poll */
  28. #define TICKS_PER_POLL (TICKS_PER_SECOND / POLLS_PER_SECOND)
  29. extern long s48_current_time;
  30. #define CHEAP_TIME() (s48_current_time * TICKS_PER_POLL)
  31. #ifndef _WIN32
  32. S48_EXTERN char s48_Spending_interruptPS;
  33. S48_EXTERN char s48_Spending_eventsPS;
  34. S48_EXTERN char *s48_Sstack_limitS;
  35. #endif
  36. /*
  37. * Fix (HCC) NOTE_EVENT so that it will act like a single
  38. * statement.
  39. */
  40. #define NOTE_EVENT \
  41. do { \
  42. s48_Spending_eventsPS = 1; \
  43. s48_Sstack_limitS = (((char *) -1)); \
  44. } while (0)
  45. /*
  46. * For Unix.
  47. */
  48. #ifdef SIGUSR1
  49. #define SIG_EXTERNAL_EVENT SIGUSR1
  50. #endif