home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / microcode / uxsig.h < prev    next >
C/C++ Source or Header  |  2000-12-05  |  3KB  |  114 lines

  1. /* -*-C-*-
  2.  
  3. $Id: uxsig.h,v 1.6 2000/12/05 21:23:49 cph Exp $
  4.  
  5. Copyright (c) 1993-2000 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21.  
  22. /* Signal Handlers */
  23.  
  24. #ifndef SCM_UXSIG_H
  25. #define SCM_UXSIG_H
  26.  
  27. #ifdef HAVE_POSIX_SIGNALS
  28.    extern void EXFUN (INSTALL_HANDLER, (int, Tsignal_handler));
  29. #else
  30. #  ifdef HAVE_SIGHOLD
  31. #    define INSTALL_HANDLER UX_sigset
  32. #    define NEED_HANDLER_TRANSACTION
  33. #    define ENTER_HANDLER(signo)
  34. #    define ABORT_HANDLER(signo, handler) UX_sigrelse (signo)
  35. #    define EXIT_HANDLER(signo, handler)
  36. #  else
  37. #    define INSTALL_HANDLER UX_signal
  38. #    define NEED_HANDLER_TRANSACTION
  39. #    define ENTER_HANDLER(signo) UX_signal ((signo), SIG_IGN)
  40. #    define ABORT_HANDLER UX_signal
  41. #    define EXIT_HANDLER UX_signal
  42. #  endif
  43. #endif
  44.  
  45. #ifndef NEED_HANDLER_TRANSACTION
  46.  
  47. #define DEFUN_STD_HANDLER(name, statement)                \
  48. Tsignal_handler_result                            \
  49. DEFUN (name, (signo, info, pscp),                    \
  50.        int signo AND                            \
  51.        SIGINFO_T info AND                        \
  52.        struct SIGCONTEXT * pscp)                    \
  53. {                                    \
  54.   int STD_HANDLER_abortp;                        \
  55.   DECLARE_FULL_SIGCONTEXT (scp);                    \
  56.   INITIALIZE_FULL_SIGCONTEXT (pscp, scp);                \
  57.   record_signal_delivery (signo);                    \
  58.   STD_HANDLER_abortp = (enter_interruption_extent ());            \
  59.   statement;                                \
  60.   if (STD_HANDLER_abortp)                        \
  61.     exit_interruption_extent ();                    \
  62.   SIGNAL_HANDLER_RETURN ();                        \
  63. }
  64.  
  65. #else /* NEED_HANDLER_TRANSACTION */
  66.  
  67. struct handler_record
  68. {
  69.   int signo;
  70.   Tsignal_handler handler;
  71. };
  72.  
  73. #define DEFUN_STD_HANDLER(name, statement)                \
  74. Tsignal_handler_result                            \
  75. DEFUN (name, (signo, info, pscp),                    \
  76.        int signo AND                            \
  77.        SIGINFO_T info AND                        \
  78.        struct SIGCONTEXT * pscp)                    \
  79. {                                    \
  80.   int STD_HANDLER_abortp;                        \
  81.   DECLARE_FULL_SIGCONTEXT (scp);                    \
  82.   INITIALIZE_FULL_SIGCONTEXT (pscp, scp);                \
  83.   ENTER_HANDLER (signo);                        \
  84.   record_signal_delivery (signo);                    \
  85.   STD_HANDLER_abortp = (enter_interruption_extent ());            \
  86.   transaction_begin ();                            \
  87.   {                                    \
  88.     struct handler_record * record =                    \
  89.       (dstack_alloc (sizeof (struct handler_record)));            \
  90.     (record -> signo) = signo;                        \
  91.     (record -> handler) = name;                        \
  92.     transaction_record_action (tat_abort, ta_abort_handler, record);    \
  93.   }                                    \
  94.   statement;                                \
  95.   if (STD_HANDLER_abortp)                        \
  96.     {                                    \
  97.       transaction_abort ();                        \
  98.       exit_interruption_extent ();                    \
  99.     }                                    \
  100.   transaction_commit ();                        \
  101.   EXIT_HANDLER (signo, name);                        \
  102.   SIGNAL_HANDLER_RETURN ();                        \
  103. }
  104.  
  105. extern void EXFUN (ta_abort_handler, (PTR));
  106.  
  107. #endif /* NEED_HANDLER_TRANSACTION */
  108.  
  109. #ifndef DEBUG_SIGNAL_DELIVERY
  110. #define record_signal_delivery(signo)
  111. #endif
  112.  
  113. #endif /* SCM_UXSIG_H */
  114.