adding GNU dc ("desk calculator")
[unix-history] / gnu / lib / libg++ / libg++ / EH.cc
CommitLineData
15637ed4
RG
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
11struct
12ExceptionHandler
13{
14 ExceptionHandler *prev;
15 jmp_buf handler;
16 void *name;
17 void *parameters;
18 ExceptionHandler ();
19 ~ExceptionHandler ();
20} EHS, *exceptionHandlerStack = &EHS;
21
22ExceptionHandler::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
39ExceptionHandler::~ExceptionHandler ()
40{
41 exceptionHandlerStack = this->prev;
42}
43