root/library/tests/unittest-cpp/Posix/SignalTranslator.h @ 706

Revision 706, 0.9 kB (checked in by smidl, 15 years ago)

eol-native

  • Property svn:eol-style set to native
Line 
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 {
10public:
11        SignalTranslator();
12        ~SignalTranslator();
13
14        static sigjmp_buf* s_jumpTarget;
15
16private:
17        sigjmp_buf m_currentJumpTarget;
18        sigjmp_buf* m_oldJumpTarget;
19
20        struct sigaction m_old_SIGFPE_action;
21        struct sigaction m_old_SIGTRAP_action;
22        struct sigaction m_old_SIGSEGV_action;
23        struct sigaction m_old_SIGBUS_action;
24        struct sigaction m_old_SIGABRT_action;
25        struct sigaction m_old_SIGALRM_action;
26};
27
28#if !defined (__GNUC__)
29#define UNITTEST_EXTENSION
30#else
31#define UNITTEST_EXTENSION __extension__
32#endif
33
34#define UNITTEST_THROW_SIGNALS \
35        UnitTest::SignalTranslator sig; \
36        if (UNITTEST_EXTENSION sigsetjmp(*UnitTest::SignalTranslator::s_jumpTarget, 1) != 0) \
37        throw ("Unhandled system exception");
38
39}
40
41#endif
Note: See TracBrowser for help on using the browser.