Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
SignalTryCatch.h
Go to the documentation of this file.
1// Partial reproduction of ROOT's TException.h
2
3/*************************************************************************
4 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef CPYCPPYY_SIGNALTRYCATCH_H
12#define CPYCPPYY_SIGNALTRYCATCH_H
13
14#include <setjmp.h>
15#include "CPyCppyy/CommonDefs.h"
16
17#ifndef _WIN32
18#define NEED_SIGJMP 1
19#endif
20
21struct ExceptionContext_t {
22#ifdef NEED_SIGJMP
23 sigjmp_buf fBuf;
24#else
25 jmp_buf fBuf;
26#endif
27};
28
29#ifdef NEED_SIGJMP
30# define SETJMP(buf) sigsetjmp(buf,1)
31#else
32# define SETJMP(buf) setjmp(buf)
33#endif
34
35#define RETRY \
36 { \
37 static ExceptionContext_t R__curr, *R__old = gException; \
38 int R__code; \
39 gException = &R__curr; \
40 R__code = SETJMP(gException->fBuf); if (R__code) { }; {
41
42#define TRY \
43 { \
44 static ExceptionContext_t R__curr, *R__old = gException; \
45 int R__code; \
46 gException = &R__curr; \
47 if ((R__code = SETJMP(gException->fBuf)) == 0) {
48
49#define CATCH(n) \
50 gException = R__old; \
51 } else { \
52 int n = R__code; \
53 gException = R__old;
54
55#define ENDTRY \
56 } \
57 gException = R__old; \
58 }
59
61
62#endif
CPYCPPYY_IMPORT ExceptionContext_t * gException
#define CPYCPPYY_IMPORT
Definition CommonDefs.h:26