Logo ROOT   6.10/09
Reference Guide
TException.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Fons Rademakers 21/09/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TException
13 #define ROOT_TException
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // Exception Handling //
19 // //
20 // Provide some macro's to simulate the coming C++ try, catch and throw //
21 // exception handling functionality. //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #ifndef __CINT__
26 #include <setjmp.h>
27 #else
28 struct sigjmp_buf;
29 struct jmp_buf;
30 #endif
31 
32 #include "RConfig.h"
33 #include "DllImport.h"
34 
36 #ifdef NEED_SIGJMP
37  sigjmp_buf fBuf;
38 #else
39  jmp_buf fBuf;
40 #endif
41 };
42 
43 #ifdef NEED_SIGJMP
44 # define SETJMP(buf) sigsetjmp(buf,1)
45 #else
46 #define SETJMP(buf) setjmp(buf)
47 #endif
48 
49 #define RETRY \
50  { \
51  static ExceptionContext_t R__curr, *R__old = gException; \
52  int R__code; \
53  gException = &R__curr; \
54  R__code = SETJMP(gException->fBuf); if (R__code) { }; {
55 
56 #define TRY \
57  { \
58  static ExceptionContext_t R__curr, *R__old = gException; \
59  int R__code; \
60  gException = &R__curr; \
61  if ((R__code = SETJMP(gException->fBuf)) == 0) {
62 
63 #define CATCH(n) \
64  gException = R__old; \
65  } else { \
66  int n = R__code; \
67  gException = R__old;
68 
69 #define ENDTRY \
70  } \
71  gException = R__old; \
72  }
73 
75 
76 extern void Throw(int code);
77 
78 #endif
R__EXTERN ExceptionContext_t * gException
Definition: TException.h:74
void Throw(int code)
If an exception context has been set (using the TRY and RETRY macros) jump back to where it was set...
Definition: TException.cxx:27
#define R__EXTERN
Definition: DllImport.h:27