aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ode-0.9/tests/CppTestHarness/SignalTranslator.h
diff options
context:
space:
mode:
authordan miller2007-10-19 05:20:07 +0000
committerdan miller2007-10-19 05:20:07 +0000
commitfca74b0bf0a0833f5701e9c0de7b3bc15b2233dd (patch)
tree51bcae7a1b8381a6bf6fd8025a7de1e30fe0045d /libraries/ode-0.9/tests/CppTestHarness/SignalTranslator.h
parentresubmitting ode (diff)
downloadopensim-SC_OLD-fca74b0bf0a0833f5701e9c0de7b3bc15b2233dd.zip
opensim-SC_OLD-fca74b0bf0a0833f5701e9c0de7b3bc15b2233dd.tar.gz
opensim-SC_OLD-fca74b0bf0a0833f5701e9c0de7b3bc15b2233dd.tar.bz2
opensim-SC_OLD-fca74b0bf0a0833f5701e9c0de7b3bc15b2233dd.tar.xz
dont ask
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