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 / intext.h < prev    next >
C/C++ Source or Header  |  1999-01-02  |  2KB  |  64 lines

  1. /* -*-C-*-
  2.  
  3. $Id: intext.h,v 1.5 1999/01/02 06:11:34 cph Exp $
  4.  
  5. Copyright (c) 1990-1999 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. #ifndef SCM_INTEXT_H
  23. #define SCM_INTEXT_H
  24.  
  25. #include "ansidecl.h"
  26. #include "dstack.h"
  27.  
  28. struct interruptable_extent
  29. {
  30.   PTR position;
  31.   jmp_buf control_point;
  32.   int interrupted;
  33. };
  34.  
  35. extern struct interruptable_extent * current_interruptable_extent;
  36. extern void EXFUN (initialize_interruptable_extent, (void));
  37. extern void EXFUN (reset_interruptable_extent, (void));
  38. extern struct interruptable_extent * EXFUN
  39.   (enter_interruptable_extent, (void));
  40. extern int EXFUN (enter_interruption_extent, (void));
  41. extern void EXFUN (exit_interruption_extent, (void));
  42.  
  43. #define INTERRUPTABLE_EXTENT(result, expression)            \
  44. {                                    \
  45.   int saved_errno;                            \
  46.   struct interruptable_extent * INTERRUPTABLE_EXTENT_frame =        \
  47.     (enter_interruptable_extent ());                    \
  48.   if ((setjmp (INTERRUPTABLE_EXTENT_frame -> control_point)) == 0)    \
  49.     {                                    \
  50.       current_interruptable_extent = INTERRUPTABLE_EXTENT_frame;    \
  51.       (result) = (expression);                        \
  52.     }                                    \
  53.   else                                    \
  54.     {                                    \
  55.       errno = EINTR;                            \
  56.       (result) = (-1);                            \
  57.     }                                    \
  58.   saved_errno = errno;                            \
  59.   dstack_set_position (current_interruptable_extent -> position);    \
  60.   errno = saved_errno;                            \
  61. }
  62.  
  63. #endif /* SCM_INTEXT_H */
  64.