ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #else
50 #define SETJMP(buf) setjmp(buf)
51 #endif
52 
53 #define RETRY \
54  { \
55  static ExceptionContext_t R__curr, *R__old = gException; \
56  int R__code; \
57  gException = &R__curr; \
58  R__code = SETJMP(gException->fBuf); if (R__code) { }; {
59 
60 #define TRY \
61  { \
62  static ExceptionContext_t R__curr, *R__old = gException; \
63  int R__code; \
64  gException = &R__curr; \
65  if ((R__code = SETJMP(gException->fBuf)) == 0) {
66 
67 #define CATCH(n) \
68  gException = R__old; \
69  } else { \
70  int n = R__code; \
71  gException = R__old;
72 
73 #define ENDTRY \
74  } \
75  gException = R__old; \
76  }
77 
79 
80 extern void Throw(int code);
81 
82 #endif
R__EXTERN ExceptionContext_t * gException
Definition: TException.h:78
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