aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ode-0.9/tests/CppTestHarness/SignalTranslator.h
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ode-0.9/tests/CppTestHarness/SignalTranslator.h')
-rw-r--r--libraries/ode-0.9/tests/CppTestHarness/SignalTranslator.h53
1 files changed, 0 insertions, 53 deletions
diff --git a/libraries/ode-0.9/tests/CppTestHarness/SignalTranslator.h b/libraries/ode-0.9/tests/CppTestHarness/SignalTranslator.h
deleted file mode 100644
index 39fc225..0000000
--- a/libraries/ode-0.9/tests/CppTestHarness/SignalTranslator.h
+++ /dev/null
@@ -1,53 +0,0 @@
1#ifndef SIGNAL_TRANSLATOR_H
2#define SIGNAL_TRANSLATOR_H
3
4#include <signal.h>
5#include <setjmp.h>
6
7namespace CppTestHarness
8{
9
10template <int SIGNAL>
11class SignalTranslator {
12public:
13 SignalTranslator()
14 {
15 //setup new signal handler
16 struct sigaction act;
17 act.sa_handler = signalHandler;
18 sigemptyset(&act.sa_mask);
19 act.sa_flags = 0;
20
21 sigaction(SIGNAL, &act, &m_oldAction);
22
23 if (sigsetjmp(getJumpPoint(), 1) != 0)
24 {
25 //if signal thrown we will return here from handler
26 throw "Unhandled system exception";
27 }
28 }
29
30 ~SignalTranslator()
31 {
32 sigaction(SIGNAL, &m_oldAction, 0);
33 }
34
35private:
36 static void signalHandler(int signum)
37 {
38 siglongjmp(getJumpPoint(), signum);
39 }
40
41 static sigjmp_buf& getJumpPoint()
42 {
43 static sigjmp_buf jmpPnt;
44 return jmpPnt;
45 }
46
47 struct sigaction m_oldAction;
48};
49
50} //CppTestHarness
51
52#endif //SIGNAL_TRANSLATOR_H
53