?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. #ifndef UNITTEST_SIGNALTRANSLATOR_H
  2. #define UNITTEST_SIGNALTRANSLATOR_H
  3.  
  4. #include <setjmp.h>
  5. #include <signal.h>
  6.  
  7. namespace UnitTest {
  8.  
  9.    class SignalTranslator
  10.    {
  11.    public:
  12.       SignalTranslator();
  13.       ~SignalTranslator();
  14.  
  15.       static sigjmp_buf* s_jumpTarget;
  16.  
  17.    private:
  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_SIGILL_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_POSIX_ONLY                                               \
  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
  42.