-
Notifications
You must be signed in to change notification settings - Fork 2
/
TryCatchSignalHandler.h
34 lines (30 loc) · 1.04 KB
/
TryCatchSignalHandler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Notes:
- This file is for backwards compatibility. Do not include it in new projects.
*/
#ifndef TRYCATCHSIGNALHANDLER_H
#define TRYCATCHSIGNALHANDLER_H
#include "TryCatchSignalHandler2.h"
#undef TRY
#undef END_TRY
#undef FINISH_TRY
// For each try sequence:
#define TRY( identifier ) \
do{\
TryCatchSignalHandler::Handler::processLevelSignal();\
TryCatchSignalHandler::Handler::preTryStatement();\
std::jmp_buf * volatile tryCatchSignalFunctionState = 0;\
try{\
tryCatchSignalFunctionState = ( std::jmp_buf * )new( std::jmp_buf ); /* safe cast? */\
TryCatchSignalHandler::Handler::pushNewFunctionState( tryCatchSignalFunctionState );\
if( setjmp( *tryCatchSignalFunctionState )==0 )
#define END_TRY( identifier ) \
TryCatchSignalHandler::Handler::processLevelSignal();\
}
#define FINISH_TRY( identifier ) \
if( tryCatchSignalFunctionState ){\
delete[] tryCatchSignalFunctionState;\
tryCatchSignalFunctionState = 0;\
}\
TryCatchSignalHandler::Handler::postTrySequence();\
}while( false )
#endif // TRYCATCHSIGNALHANDLER_H