ROOT  6.06/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 #ifndef ROOT_RConfig
33 #include "RConfig.h"
34 #endif
35 #ifndef ROOT_DllImport
36 #include "DllImport.h"
37 #endif
38 
40 #ifdef NEED_SIGJMP
41  sigjmp_buf fBuf;
42 #else
43  jmp_buf fBuf;
44 #endif
45 };
46 
47 #ifdef NEED_SIGJMP
48 # define SETJMP(buf) sigsetjmp(buf,1)
49 # ifdef __has_feature
50 # if __has_feature(modules) // A not implemented in the modulemaps macro re-export
51 # undef SETJMP
52 # define SETJMP(buf) __sigsetjmp(buf,1)
53 # endif
54 # endif
55 #else
56 #define SETJMP(buf) setjmp(buf)
57 #endif
58 
59 #define RETRY \
60  { \
61  static ExceptionContext_t R__curr, *R__old = gException; \
62  int R__code; \
63  gException = &R__curr; \
64  R__code = SETJMP(gException->fBuf); if (R__code) { }; {
65 
66 #define TRY \
67  { \
68  static ExceptionContext_t R__curr, *R__old = gException; \
69  int R__code; \
70  gException = &R__curr; \
71  if ((R__code = SETJMP(gException->fBuf)) == 0) {
72 
73 #define CATCH(n) \
74  gException = R__old; \
75  } else { \
76  int n = R__code; \
77  gException = R__old;
78 
79 #define ENDTRY \
80  } \
81  gException = R__old; \
82  }
83 
85 
86 extern void Throw(int code);
87 
88 #endif
R__EXTERN ExceptionContext_t * gException
Definition: TException.h:84
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