G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
SignalTranslator.h
1#ifndef UNITTEST_SIGNALTRANSLATOR_H
2#define UNITTEST_SIGNALTRANSLATOR_H
3
4#include <setjmp.h>
5#include <signal.h>
6
7namespace UnitTest {
8
9class SignalTranslator
10{
11public:
12 SignalTranslator();
13 ~SignalTranslator();
14
15 static sigjmp_buf* s_jumpTarget;
16
17private:
18 sigjmp_buf m_currentJumpTarget;
19 sigjmp_buf* m_oldJumpTarget;
20
21 struct sigaction m_old_SIGFPE_action;
22 struct sigaction m_old_SIGTRAP_action;
23 struct sigaction m_old_SIGSEGV_action;
24 struct sigaction m_old_SIGBUS_action;
25 //struct sigaction m_old_SIGABRT_action; //G+Smo: not used
26 //struct sigaction m_old_SIGALRM_action; //G+Smo: not used
27};
28
29#if !defined (__GNUC__)
30 #define UNITTEST_EXTENSION
31#else
32 #define UNITTEST_EXTENSION __extension__
33#endif
34
35#define UNITTEST_THROW_SIGNALS_POSIX_ONLY \
36 UnitTest::SignalTranslator sig; \
37 if (UNITTEST_EXTENSION sigsetjmp(*UnitTest::SignalTranslator::s_jumpTarget, 1) != 0) \
38 { throw ("Unhandled system exception"); }
39
40}
41
42#endif