home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / gplibs07 / xeh.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-24  |  757 b   |  44 lines

  1. /* Library code for programs which use -fhandle-exceptions.
  2.    Note: do *not* compile this with -fhandle-exceptions.  */
  3.  
  4.  
  5. #ifdef __GNUG__
  6. #pragma implementation
  7. #endif
  8. #include <setjmp.h>
  9. #include <stream.h>
  10.  
  11. struct
  12. ExceptionHandler
  13. {
  14.   ExceptionHandler *prev;
  15.   jmp_buf handler;
  16.   void *name;
  17.   void *parameters;
  18.   ExceptionHandler ();
  19.   ~ExceptionHandler ();
  20. } EHS, *exceptionHandlerStack = &EHS;
  21.  
  22. ExceptionHandler::ExceptionHandler ()
  23. {
  24.   if (this == &EHS)
  25.     {
  26.       if (setjmp (EHS.handler))
  27.     {
  28.       cerr << ("unhandled exception, aborting...\n");
  29.       abort ();
  30.     }
  31.     }
  32.   else
  33.     {
  34.       this->prev = exceptionHandlerStack;
  35.       exceptionHandlerStack = this;
  36.     }
  37. }
  38.  
  39. ExceptionHandler::~ExceptionHandler ()
  40. {
  41.   exceptionHandlerStack = this->prev;
  42. }
  43.  
  44.